Skip to content

Commit 743b976

Browse files
authored
Rollup merge of rust-lang#46985 - Diggsey:path-component-asref, r=alexcrichton
Implement AsRef<Path> for Component Fixes rust-lang#41866
2 parents 0b90e4e + e0855ff commit 743b976

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libstd/path.rs

+7
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,13 @@ impl<'a> AsRef<OsStr> for Component<'a> {
576576
}
577577
}
578578

579+
#[stable(feature = "path_component_asref", since = "1.24.0")]
580+
impl<'a> AsRef<Path> for Component<'a> {
581+
fn as_ref(&self) -> &Path {
582+
self.as_os_str().as_ref()
583+
}
584+
}
585+
579586
/// An iterator over the [`Component`]s of a [`Path`].
580587
///
581588
/// This `struct` is created by the [`components`] method on [`Path`].

0 commit comments

Comments
 (0)