We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ed084b0 + bdfdc71 commit 86f48c5Copy full SHA for 86f48c5
src/libstd/ffi/os_str.rs
@@ -4,6 +4,7 @@ use crate::fmt;
4
use crate::hash::{Hash, Hasher};
5
use crate::ops;
6
use crate::rc::Rc;
7
+use crate::str::FromStr;
8
use crate::sync::Arc;
9
10
use crate::sys::os_str::{Buf, Slice};
@@ -1174,6 +1175,15 @@ impl AsInner<Slice> for OsStr {
1174
1175
}
1176
1177
1178
+#[stable(feature = "osstring_from_str", since = "1.45.0")]
1179
+impl FromStr for OsString {
1180
+ type Err = core::convert::Infallible;
1181
+
1182
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
1183
+ Ok(OsString::from(s))
1184
+ }
1185
+}
1186
1187
#[cfg(test)]
1188
mod tests {
1189
use super::*;
0 commit comments