]> git.lizzy.rs Git - rust.git/commitdiff
Add cstring_from_cow_cstr and osstring_from_cow_osstr
authorGeorge Burton <burtonageo@gmail.com>
Fri, 27 Apr 2018 19:27:38 +0000 (20:27 +0100)
committerGeorge Burton <burtonageo@gmail.com>
Fri, 27 Apr 2018 19:27:38 +0000 (20:27 +0100)
src/libstd/ffi/c_str.rs
src/libstd/ffi/os_str.rs

index 08a1596ef25f68e005701f45ec665b0ad33a3e7c..7f38cadfb22adcf0006e36dd48660e5635400e8e 100644 (file)
@@ -682,6 +682,14 @@ impl Borrow<CStr> for CString {
     fn borrow(&self) -> &CStr { self }
 }
 
+#[stable(feature = "cstring_from_cow_cstr", since = "1.28.0")]
+impl<'a> From<Cow<'a, CStr>> for CString {
+    #[inline]
+    fn from(s: Cow<'a, CStr>) -> Self {
+        s.into_owned()
+    }
+}
+
 #[stable(feature = "box_from_c_str", since = "1.17.0")]
 impl<'a> From<&'a CStr> for Box<CStr> {
     fn from(s: &'a CStr) -> Box<CStr> {
index e42a28ed88f8243f0764ef8cf63ae67c8a4b67c9..0a3148029d053ce1fbac909bf77dd0d77fcf3053 100644 (file)
@@ -688,6 +688,14 @@ fn from(s: &'a OsString) -> Cow<'a, OsStr> {
     }
 }
 
+#[stable(feature = "osstring_from_cow_osstr", since = "1.28.0")]
+impl<'a> From<Cow<'a, OsStr>> for OsString {
+    #[inline]
+    fn from(s: Cow<'a, OsStr>) -> Self {
+        s.into_owned()
+    }
+}
+
 #[stable(feature = "box_default_extra", since = "1.17.0")]
 impl Default for Box<OsStr> {
     fn default() -> Box<OsStr> {