Implement AsRef<Path> for Component
This commit is contained in:
parent
304717bd86
commit
e0855ff4a1
1 changed files with 7 additions and 0 deletions
|
@ -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`].
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue