Skip to content

Commit

Permalink
Rollup merge of rust-lang#55148 - SimonSapin:path-fromstr, r=oli-obk
Browse files Browse the repository at this point in the history
Implement FromStr for PathBuf

Initially landed in rust-lang#48292 and reverted in rust-lang#50401. This time, use `std::string::ParseError` as suggested in rust-lang#44431 (comment)
  • Loading branch information
kennytm committed Oct 28, 2018
2 parents 1982f18 + a0df420 commit b9763de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libstd/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b9763de

Please sign in to comment.