Skip to content

Commit 318536a

Browse files
committed
Auto merge of #51912 - mbrubeck:more_box_slice_clone, r=alexcrichton
impl Clone for Box<CStr>, Box<OsStr>, Box<Path> Implements #51908.
2 parents d573fe1 + cdff2f3 commit 318536a

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/libstd/ffi/c_str.rs

+8
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
706706
}
707707
}
708708

709+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
710+
impl Clone for Box<CStr> {
711+
#[inline]
712+
fn clone(&self) -> Self {
713+
(**self).into()
714+
}
715+
}
716+
709717
#[stable(feature = "box_from_c_string", since = "1.20.0")]
710718
impl From<CString> for Box<CStr> {
711719
#[inline]

src/libstd/ffi/os_str.rs

+8
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,14 @@ impl From<OsString> for Box<OsStr> {
642642
}
643643
}
644644

645+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
646+
impl Clone for Box<OsStr> {
647+
#[inline]
648+
fn clone(&self) -> Self {
649+
self.to_os_string().into_boxed_os_str()
650+
}
651+
}
652+
645653
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
646654
impl From<OsString> for Arc<OsStr> {
647655
#[inline]

src/libstd/path.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
14101410
}
14111411
}
14121412

1413+
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
1414+
impl Clone for Box<Path> {
1415+
#[inline]
1416+
fn clone(&self) -> Self {
1417+
self.to_path_buf().into_boxed_path()
1418+
}
1419+
}
1420+
14131421
#[stable(feature = "rust1", since = "1.0.0")]
14141422
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
14151423
fn from(s: &'a T) -> PathBuf {

0 commit comments

Comments
 (0)