about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2020-04-29 18:13:52 +0900
committerMike Hommey <mh@glandium.org>2020-04-29 18:13:52 +0900
commitbdfdc71d0f56a592fd888fcd89e6e9c6188b156c (patch)
treeb1453954798a24f2c53ab993f39721d736a41112
parent92019986aa6532256277ca999006bdc77e9a95ad (diff)
downloadrust-bdfdc71d0f56a592fd888fcd89e6e9c6188b156c.tar.gz
rust-bdfdc71d0f56a592fd888fcd89e6e9c6188b156c.zip
Implement FromStr for OsString
-rw-r--r--src/libstd/ffi/os_str.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index 4fde3316973..7a05aaf71f2 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -4,6 +4,7 @@ use crate::fmt;
 use crate::hash::{Hash, Hasher};
 use crate::ops;
 use crate::rc::Rc;
+use crate::str::FromStr;
 use crate::sync::Arc;
 
 use crate::sys::os_str::{Buf, Slice};
@@ -1174,6 +1175,15 @@ impl AsInner<Slice> for OsStr {
     }
 }
 
+#[stable(feature = "osstring_from_str", since = "1.45.0")]
+impl FromStr for OsString {
+    type Err = core::convert::Infallible;
+
+    fn from_str(s: &str) -> Result<Self, Self::Err> {
+        Ok(OsString::from(s))
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;