diff options
| author | bors <bors@rust-lang.org> | 2024-08-17 11:39:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-17 11:39:08 +0000 |
| commit | c6f81a452e291dd4ff5bcbc6ecb9cd6f2271f164 (patch) | |
| tree | 190cb968c33ad6d4bbbdcc7221cb54507ec97a8b /library/std/src/path.rs | |
| parent | 426a60abc213b28a7c7198e475476b6e650d871f (diff) | |
| parent | 110c273f4fb40c318be59a557ba90314fbbc42a6 (diff) | |
| download | rust-c6f81a452e291dd4ff5bcbc6ecb9cd6f2271f164.tar.gz rust-c6f81a452e291dd4ff5bcbc6ecb9cd6f2271f164.zip | |
Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnay
CloneToUninit impls As per #126799. Also implements it for `Wtf8` and both versions of `os_str::Slice`. Maybe it is worth to slap `#[inline]` on some of those impls. r? `@dtolnay`
Diffstat (limited to 'library/std/src/path.rs')
| -rw-r--r-- | library/std/src/path.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 80163667636..9eaa0e01c2c 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -70,6 +70,8 @@ #[cfg(test)] mod tests; +use core::clone::CloneToUninit; + use crate::borrow::{Borrow, Cow}; use crate::collections::TryReserveError; use crate::error::Error; @@ -3109,6 +3111,16 @@ impl Path { } } +#[unstable(feature = "clone_to_uninit", issue = "126799")] +unsafe impl CloneToUninit for Path { + #[inline] + #[cfg_attr(debug_assertions, track_caller)] + unsafe fn clone_to_uninit(&self, dst: *mut Self) { + // SAFETY: Path is just a wrapper around OsStr + unsafe { self.inner.clone_to_uninit(core::ptr::addr_of_mut!((*dst).inner)) } + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl AsRef<OsStr> for Path { #[inline] |
