Skip to content

Commit

Permalink
Merge #32
Browse files Browse the repository at this point in the history
32: fix i32 / u32 uDebug impl for 16-bit pointer width r=japaric a=mrk-its

fixes #28

Co-authored-by: Mariusz Kryński <mrk@sed.pl>
  • Loading branch information
bors[bot] and mrk-its authored Aug 9, 2022
2 parents 8f1c440 + e6e5746 commit 03ad752
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 03ad752

Please sign in to comment.