impl CloneToUninit for Path and OsStr
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
//! The underlying OsString/OsStr implementation on Unix and many other
|
||||
//! systems: just a `Vec<u8>`/`[u8]`.
|
||||
|
||||
use core::clone::CloneToUninit;
|
||||
use core::ptr::addr_of_mut;
|
||||
|
||||
use crate::borrow::Cow;
|
||||
use crate::collections::TryReserveError;
|
||||
use crate::fmt::Write;
|
||||
@@ -345,3 +348,12 @@ impl Slice {
|
||||
self.inner.eq_ignore_ascii_case(&other.inner)
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "clone_to_uninit", issue = "126799")]
|
||||
unsafe impl CloneToUninit for Slice {
|
||||
#[cfg_attr(debug_assertions, track_caller)]
|
||||
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
|
||||
// SAFETY: we're just a wrapper around [u8]
|
||||
unsafe { self.inner.clone_to_uninit(addr_of_mut!((*dst).inner)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
//! The underlying OsString/OsStr implementation on Windows is a
|
||||
//! wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
|
||||
use core::clone::CloneToUninit;
|
||||
use core::ptr::addr_of_mut;
|
||||
|
||||
use crate::borrow::Cow;
|
||||
use crate::collections::TryReserveError;
|
||||
use crate::rc::Rc;
|
||||
@@ -268,3 +271,12 @@ impl Slice {
|
||||
self.inner.eq_ignore_ascii_case(&other.inner)
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "clone_to_uninit", issue = "126799")]
|
||||
unsafe impl CloneToUninit for Slice {
|
||||
#[cfg_attr(debug_assertions, track_caller)]
|
||||
unsafe fn clone_to_uninit(&self, dst: *mut Self) {
|
||||
// SAFETY: we're just a wrapper around Wtf8
|
||||
unsafe { self.inner.clone_to_uninit(addr_of_mut!((*dst).inner)) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user