From 05a9acc3b844ff284a3e3d85dde2d9798abfb215 Mon Sep 17 00:00:00 2001
From: topecongiro <seuchida@gmail.com>
Date: Sun, 18 Feb 2018 00:36:57 +0900
Subject: [PATCH] Implement FromStr for PathBuf

---
 src/libstd/path.rs | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index e03a182653e..a41f76228a9 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -87,6 +87,7 @@ use io;
 use iter::{self, FusedIterator};
 use ops::{self, Deref};
 use rc::Rc;
+use str::FromStr;
 use sync::Arc;
 
 use ffi::{OsStr, OsString};
@@ -1397,6 +1398,32 @@ impl From<String> for PathBuf {
     }
 }
 
+/// Error returned from [`PathBuf::from_str`][`from_str`].
+///
+/// Note that parsing a path will never fail. This error is just a placeholder
+/// for implementing `FromStr` for `PathBuf`.
+///
+/// [`from_str`]: struct.PathBuf.html#method.from_str
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[stable(feature = "path_from_str", since = "1.26.0")]
+pub enum ParsePathError {}
+
+#[stable(feature = "path_from_str", since = "1.26.0")]
+impl fmt::Display for ParsePathError {
+    fn fmt(&self, _: &mut fmt::Formatter) -> fmt::Result {
+        match *self {}
+    }
+}
+
+#[stable(feature = "path_from_str", since = "1.26.0")]
+impl FromStr for PathBuf {
+    type Err = ParsePathError;
+
+    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 {