Skip to content

Commit

Permalink
Implement FromStr for OsString
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Apr 29, 2020
1 parent 9201998 commit bdfdc71
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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::*;
Expand Down

0 comments on commit bdfdc71

Please sign in to comment.