Skip to content

Commit c8893fa

Browse files
committed
deprecated MaybeUninit slice conversion
1 parent 3b4f777 commit c8893fa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/core/src/fmt/num.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ macro_rules! impl_Display {
295295
// not used: remain = 0;
296296
}
297297

298-
// SAFETY: Offset has been used as a write index.
299-
unsafe { core::hint::assert_unchecked(offset < buf.len()) }
300-
let written = &buf[offset..];
301298
// SAFETY: All buf content since offset is set with bytes form
302299
// the lookup table, which consists of valid ASCII exclusively.
303300
f.pad_integral(is_nonnegative, "", unsafe {
304-
let as_init = MaybeUninit::slice_assume_init_ref(written);
305-
str::from_utf8_unchecked(as_init)
301+
let written = buf.get_unchecked(offset..);
302+
str::from_utf8_unchecked(slice::from_raw_parts(
303+
MaybeUninit::slice_as_ptr(written),
304+
written.len(),
305+
))
306306
})
307307
}
308308
})*

0 commit comments

Comments
 (0)