about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-01-13 02:26:22 +0800
committerGitHub <noreply@github.com>2018-01-13 02:26:22 +0800
commit743b976b369bec2784544b0e48d915ca8d44cfbc (patch)
tree397a8cf81c22bf8af53b9bd8f26161bc5ed8820e /src/libstd
parent0b90e4e8cd068910f604f3e1fb5d03cc01f1658f (diff)
parente0855ff4a13ea79daa56d23a25f827fe86e8147b (diff)
downloadrust-743b976b369bec2784544b0e48d915ca8d44cfbc.tar.gz
rust-743b976b369bec2784544b0e48d915ca8d44cfbc.zip
Rollup merge of #46985 - Diggsey:path-component-asref, r=alexcrichton
Implement AsRef<Path> for Component

Fixes #41866
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 bed9efcb846..e8297c20af3 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`].