about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDiggory Blake <diggsey@googlemail.com>2017-12-24 17:02:24 +0000
committerDiggory Blake <diggsey@googlemail.com>2017-12-28 13:27:53 +0000
commite0855ff4a13ea79daa56d23a25f827fe86e8147b (patch)
tree6c4b1daa649e683bcd51857a80c7e4c8d0d9d15a /src/libstd
parent304717bd86e42bc9b0c45ea5a6068e7ed9d13f2f (diff)
downloadrust-e0855ff4a13ea79daa56d23a25f827fe86e8147b.tar.gz
rust-e0855ff4a13ea79daa56d23a25f827fe86e8147b.zip
Implement AsRef<Path> for Component
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/path.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs
index eb125a4737a..ff528903b75 100644
--- a/src/libstd/path.rs
+++ b/src/libstd/path.rs
@@ -576,6 +576,13 @@ impl<'a> AsRef<OsStr> for Component<'a> {
     }
 }
 
+#[stable(feature = "path_component_asref", since = "1.24.0")]
+impl<'a> AsRef<Path> for Component<'a> {
+    fn as_ref(&self) -> &Path {
+        self.as_os_str().as_ref()
+    }
+}
+
 /// An iterator over the [`Component`]s of a [`Path`].
 ///
 /// This `struct` is created by the [`components`] method on [`Path`].