Skip to content

Commit

Permalink
Touch up PR 45
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 20, 2024
1 parent 63a8c86 commit db0ce57
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

mod udiv128;

use core::hint;
use core::mem::{self, MaybeUninit};
use core::{ptr, slice, str};
#[cfg(feature = "no-panic")]
Expand Down Expand Up @@ -95,14 +96,14 @@ impl Buffer {
/// representation within the buffer.
#[cfg_attr(feature = "no-panic", no_panic)]
pub fn format<I: Integer>(&mut self, i: I) -> &str {
let str = i.write(unsafe {
let string = i.write(unsafe {
&mut *(&mut self.bytes as *mut [MaybeUninit<u8>; I128_MAX_LEN]
as *mut <I as private::Sealed>::Buffer)
});
if str.len() > I::MAX_STR_LEN {
unsafe { core::hint::unreachable_unchecked() }
if string.len() > I::MAX_STR_LEN {
unsafe { hint::unreachable_unchecked() };
}
str
string
}
}

Expand Down

0 comments on commit db0ce57

Please sign in to comment.