Rollup merge of #46985 - Diggsey:path-component-asref, r=alexcrichton

Implement AsRef<Path> for Component

Fixes #41866
This commit is contained in:
kennytm
2018-01-13 02:26:22 +08:00
committed by GitHub

View File

@@ -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`].