Skip to content

Commit 6e253cd

Browse files
committed
Implement AsRef<OsStr> for Cow<'_, Path>
In #331751, `impl AsRef<Path> for Cow<'_, OsStr>` was added, but the converse was omitted and it wasn't mentioned in discussion. This seems to have been a simple oversight, as it otherwise implemented traits mutually between `OsStr` and `Path`.
1 parent c211076 commit 6e253cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/path.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3173,6 +3173,14 @@ impl AsRef<OsStr> for Path {
31733173
}
31743174
}
31753175

3176+
#[stable(feature = "cow_path_as_ref_os_str", since = "CURRENT_RUSTC_VERSION")]
3177+
impl AsRef<OsStr> for Cow<'_, Path> {
3178+
#[inline]
3179+
fn as_ref(&self) -> &OsStr {
3180+
self.as_os_str()
3181+
}
3182+
}
3183+
31763184
#[stable(feature = "rust1", since = "1.0.0")]
31773185
impl fmt::Debug for Path {
31783186
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {

0 commit comments

Comments
 (0)