Implement FromStr for OsString
This commit is contained in:
parent
92019986aa
commit
bdfdc71d0f
@ -4,6 +4,7 @@ use crate::fmt;
|
|||||||
use crate::hash::{Hash, Hasher};
|
use crate::hash::{Hash, Hasher};
|
||||||
use crate::ops;
|
use crate::ops;
|
||||||
use crate::rc::Rc;
|
use crate::rc::Rc;
|
||||||
|
use crate::str::FromStr;
|
||||||
use crate::sync::Arc;
|
use crate::sync::Arc;
|
||||||
|
|
||||||
use crate::sys::os_str::{Buf, Slice};
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user