We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3b4f777 commit c8893faCopy full SHA for c8893fa
library/core/src/fmt/num.rs
@@ -295,14 +295,14 @@ macro_rules! impl_Display {
295
// not used: remain = 0;
296
}
297
298
- // SAFETY: Offset has been used as a write index.
299
- unsafe { core::hint::assert_unchecked(offset < buf.len()) }
300
- let written = &buf[offset..];
301
// SAFETY: All buf content since offset is set with bytes form
302
// the lookup table, which consists of valid ASCII exclusively.
303
f.pad_integral(is_nonnegative, "", unsafe {
304
- let as_init = MaybeUninit::slice_assume_init_ref(written);
305
- str::from_utf8_unchecked(as_init)
+ let written = buf.get_unchecked(offset..);
+ str::from_utf8_unchecked(slice::from_raw_parts(
+ MaybeUninit::slice_as_ptr(written),
+ written.len(),
+ ))
306
})
307
308
})*
0 commit comments