1
Fork 0

Implement FromStr for PathBuf

Initially landed in https://github.com/rust-lang/rust/pull/48292
and reverted in https://github.com/rust-lang/rust/pull/50401.
This time, use `std::string::ParseError` as suggested in
https://github.com/rust-lang/rust/issues/44431#issuecomment-428112632
This commit is contained in:
Simon Sapin 2018-10-17 15:51:10 +02:00
parent cbbd70d4f2
commit a0df4204c4

View file

@ -87,6 +87,8 @@ use io;
use iter::{self, FusedIterator};
use ops::{self, Deref};
use rc::Rc;
use str::FromStr;
use string::ParseError;
use sync::Arc;
use ffi::{OsStr, OsString};
@ -1443,6 +1445,15 @@ impl From<String> for PathBuf {
}
}
#[stable(feature = "path_from_str", since = "1.26.0")]
impl FromStr for PathBuf {
type Err = ParseError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(PathBuf::from(s))
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {