Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix i32 / u32 uDebug impl for 16-bit pointer width #32

Merged
merged 1 commit into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/impls/ixx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl uDisplay for i16 {
}

impl uDebug for i32 {
#[cfg(not(target_pointer_width = "16"))]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
Expand All @@ -94,6 +95,16 @@ impl uDebug for i32 {

f.write_str(isize(*self as isize, &mut buf))
}
#[cfg(target_pointer_width = "16")]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
let mut buf: [u8; 11] = unsafe { crate::uninitialized() };

let s = ixx!(u32, *self, buf);
f.write_str(s)
}
}

impl uDisplay for i32 {
Expand Down
10 changes: 10 additions & 0 deletions src/impls/uxx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ impl uDisplay for u16 {
}

impl uDebug for u32 {
#[cfg(not(target_pointer_width = "16"))]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
Expand All @@ -78,6 +79,15 @@ impl uDebug for u32 {

f.write_str(usize(*self as usize, &mut buf))
}
#[cfg(target_pointer_width = "16")]
fn fmt<W>(&self, f: &mut Formatter<'_, W>) -> Result<(), W::Error>
where
W: uWrite + ?Sized,
{
let mut buf: [u8; 10] = unsafe { crate::uninitialized() };
let s = uxx!(*self, buf);
f.write_str(s)
}
}

impl uDisplay for u32 {
Expand Down