diff options
| author | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-06-23 23:05:10 +0300 |
|---|---|---|
| committer | Pavel Grigorenko <GrigorenkoPV@ya.ru> | 2024-07-29 20:44:39 +0300 |
| commit | afabc583f7f646d45f506263a1c331383ebdc252 (patch) | |
| tree | df95c9b8b394722c04dd8c6e865c8275e946f0ad /library/std/src/sys/os_str/bytes.rs | |
| parent | ec921db289ea87fd4030cb7f8a70f6ba3a31c2c7 (diff) | |
| download | rust-afabc583f7f646d45f506263a1c331383ebdc252.tar.gz rust-afabc583f7f646d45f506263a1c331383ebdc252.zip | |
impl CloneToUninit for Path and OsStr
Diffstat (limited to 'library/std/src/sys/os_str/bytes.rs')
| -rw-r--r-- | library/std/src/sys/os_str/bytes.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index 0f8bd645352..8529207366e 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -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)) } + } +} |
