about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatt Brubeck <mbrubeck@limpet.net>2018-06-29 11:49:32 -0700
committerMatt Brubeck <mbrubeck@limpet.net>2018-07-06 12:57:47 -0700
commitcdff2f3b3083f602736653e1428b5113dd2e7eee (patch)
treefa8cbcc5a463ddd0475d49d17028e16a8a87fcc2 /src
parent5fdcd3aa389aa92879f576c55e429015667143c3 (diff)
downloadrust-cdff2f3b3083f602736653e1428b5113dd2e7eee.tar.gz
rust-cdff2f3b3083f602736653e1428b5113dd2e7eee.zip
impl Clone for Box<CStr>, Box<OsStr>, Box<Path>
Implements #51908.
Diffstat (limited to 'src')
-rw-r--r--src/libstd/ffi/c_str.rs8
-rw-r--r--src/libstd/ffi/os_str.rs8
-rw-r--r--src/libstd/path.rs8
3 files changed, 24 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 6513d11dd51..b816f4b7850 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
     }
 }
 
+#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
+impl Clone for Box<CStr> {
+    #[inline]
+    fn clone(&self) -> Self {
+        (**self).into()
+    }
+}
+
 #[stable(feature = "box_from_c_string", since = "1.20.0")]
 impl From<CString> for Box<CStr> {
     #[inline]
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index 0a3148029d0..b522d134837 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -628,6 +628,14 @@ impl From<OsString> for Box<OsStr> {
     }
 }
 
+#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
+impl Clone for Box<OsStr> {
+    #[inline]
+    fn clone(&self) -> Self {
+        self.to_os_string().into_boxed_os_str()
+    }
+}
+
 #[stable(feature = "shared_from_slice2", since = "1.24.0")]
 impl From<OsString> for Arc<OsStr> {
     #[inline]
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index 3dc1e9c3dad..2d868629278 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
     }
 }
 
+#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
+impl Clone for Box<Path> {
+    #[inline]
+    fn clone(&self) -> Self {
+        self.to_path_buf().into_boxed_path()
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
     fn from(s: &'a T) -> PathBuf {