Implement FromStr for OsString

This commit is contained in:
Mike Hommey 2020-04-29 18:13:52 +09:00
parent 92019986aa
commit bdfdc71d0f

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