]> git.lizzy.rs Git - rust.git/commitdiff
impl Clone for Box<CStr>, Box<OsStr>, Box<Path>
authorMatt Brubeck <mbrubeck@limpet.net>
Fri, 29 Jun 2018 18:49:32 +0000 (11:49 -0700)
committerMatt Brubeck <mbrubeck@limpet.net>
Fri, 6 Jul 2018 19:57:47 +0000 (12:57 -0700)
Implements #51908.

src/libstd/ffi/c_str.rs
src/libstd/ffi/os_str.rs
src/libstd/path.rs

index 6513d11dd517c436c25afe16c7def1f54d1cea0c..b816f4b7850efb17aaea0f3e4b0bcca774a838a4 100644 (file)
@@ -706,6 +706,14 @@ fn from(s: Box<CStr>) -> 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]
index 0a3148029d053ce1fbac909bf77dd0d77fcf3053..b522d1348378ca7e85eb632d32c6bffa789efd9e 100644 (file)
@@ -628,6 +628,14 @@ fn from(s: OsString) -> 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]
index 3dc1e9c3dadc85ff4c5c250d8f0d58a68c997fe5..2d8686292788448fa13b98156fdaab240cfabcb4 100644 (file)
@@ -1410,6 +1410,14 @@ fn from(p: PathBuf) -> 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 {