Skip to content

Commit

Permalink
fix i32 / u32 uDebug impl for 16-bit pointer width
Browse files Browse the repository at this point in the history
  • Loading branch information
mrk-its committed Jan 16, 2022
1 parent 4cbb956 commit e6e5746
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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

0 comments on commit e6e5746

Please sign in to comment.