Skip to content

Commit

Permalink
deprecated MaybeUninit slice conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
pascaldekloe committed Jan 21, 2025
1 parent f04f05b commit 651707f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/core/src/fmt/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,14 @@ macro_rules! impl_Display {
// not used: remain = 0;
}

// SAFETY: Offset has been used as a write index.
unsafe { core::hint::assert_unchecked(offset < buf.len()) }
let written = &buf[offset..];
// SAFETY: All buf content since offset is set with bytes form
// the lookup table, which consists of valid ASCII exclusively.
f.pad_integral(is_nonnegative, "", unsafe {
let as_init = MaybeUninit::slice_assume_init_ref(written);
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(),
))
})
}
})*
Expand Down

0 comments on commit 651707f

Please sign in to comment.