1
Fork 0

Auto merge of #116385 - kornelski:maybe-rename, r=Amanieu

Rename MaybeUninit::write_slice

A step to push #79995 forward.

https://github.com/rust-lang/libs-team/issues/122 also suggested to make them inherent methods, but they can't be — they'd conflict with slice's regular methods.
This commit is contained in:
bors 2024-02-16 14:11:10 +00:00
commit ae9d7b0c64
5 changed files with 22 additions and 22 deletions

View file

@ -105,7 +105,7 @@ impl Arena {
#[allow(clippy::mut_from_ref)] // arena allocator
pub(crate) fn alloc_str<'a>(&'a self, string: &str) -> &'a mut str {
let alloc = self.alloc_raw(string.len());
let bytes = MaybeUninit::write_slice(alloc, string.as_bytes());
let bytes = MaybeUninit::copy_from_slice(alloc, string.as_bytes());
// SAFETY: we convert from `&str` to `&[u8]`, clone it into the arena,
// and immediately convert the clone back to `&str`.