Skip to content

Commit

Permalink
Rollup merge of #71662 - glandium:osstring_from_str, r=sfackler
Browse files Browse the repository at this point in the history
Implement FromStr for OsString
  • Loading branch information
Dylan-DPC authored May 16, 2020
2 parents ed084b0 + bdfdc71 commit 86f48c5
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 86f48c5

Please sign in to comment.