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`.
This commit is contained in:
Thalia Archibald 2025-04-05 18:18:31 -07:00
parent c2110769cd
commit 781b92c3f1
2 changed files with 9 additions and 1 deletions

View File

@ -3173,6 +3173,14 @@ impl AsRef<OsStr> for Path {
}
}
#[stable(feature = "cow_path_as_ref_os_str", since = "CURRENT_RUSTC_VERSION")]
impl AsRef<OsStr> for Cow<'_, Path> {
#[inline]
fn as_ref(&self) -> &OsStr {
self.as_os_str()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for Path {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {

View File

@ -941,7 +941,7 @@ impl<'test> TestCx<'test> {
.arg("-L")
.arg(aux_dir)
.arg("-o")
.arg(out_dir.as_ref())
.arg(out_dir)
.arg("--deny")
.arg("warnings")
.arg(&self.testpaths.file)