Rollup merge of #71662 - glandium:osstring_from_str, r=sfackler

Implement FromStr for OsString
This commit is contained in:
Dylan DPC 2020-05-16 02:37:07 +02:00 committed by GitHub
commit 86f48c5311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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::*;