Skip to content

Commit ef8f09a

Browse files
Rollup merge of rust-lang#55148 - SimonSapin:path-fromstr, r=oli-obk
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)
2 parents 80c1f0b + a0df420 commit ef8f09a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libstd/path.rs

+11
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ use io;
8787
use iter::{self, FusedIterator};
8888
use ops::{self, Deref};
8989
use rc::Rc;
90+
use str::FromStr;
91+
use string::ParseError;
9092
use sync::Arc;
9193

9294
use ffi::{OsStr, OsString};
@@ -1443,6 +1445,15 @@ impl From<String> for PathBuf {
14431445
}
14441446
}
14451447

1448+
#[stable(feature = "path_from_str", since = "1.26.0")]
1449+
impl FromStr for PathBuf {
1450+
type Err = ParseError;
1451+
1452+
fn from_str(s: &str) -> Result<Self, Self::Err> {
1453+
Ok(PathBuf::from(s))
1454+
}
1455+
}
1456+
14461457
#[stable(feature = "rust1", since = "1.0.0")]
14471458
impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf {
14481459
fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf {

0 commit comments

Comments
 (0)