impl CloneToUninit for Path and OsStr

This commit is contained in:
Pavel Grigorenko
2024-06-23 23:05:10 +03:00
parent ec921db289
commit afabc583f7
8 changed files with 95 additions and 0 deletions

View File

@@ -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,15 @@ impl Path {
}
}
#[unstable(feature = "clone_to_uninit", issue = "126799")]
unsafe impl CloneToUninit for Path {
#[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]