Skip to content

Commit 781b92c

Browse files
committed
Implement AsRef<OsStr> for Cow<'_, Path>
In #31751, `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 781b92c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

library/std/src/path.rs

+8
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 {

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl<'test> TestCx<'test> {
941941
.arg("-L")
942942
.arg(aux_dir)
943943
.arg("-o")
944-
.arg(out_dir.as_ref())
944+
.arg(out_dir)
945945
.arg("--deny")
946946
.arg("warnings")
947947
.arg(&self.testpaths.file)

0 commit comments

Comments
 (0)