Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/paths/src/lib.rs')
| -rw-r--r-- | crates/paths/src/lib.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/crates/paths/src/lib.rs b/crates/paths/src/lib.rs index 3ffe4e11e9..2d3653401d 100644 --- a/crates/paths/src/lib.rs +++ b/crates/paths/src/lib.rs @@ -13,7 +13,7 @@ use std::{ pub use camino::*; /// Wrapper around an absolute [`Utf8PathBuf`]. -#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq, Hash)] +#[derive(Debug, Clone, Ord, PartialOrd, Eq, Hash)] pub struct AbsPathBuf(Utf8PathBuf); impl From<AbsPathBuf> for Utf8PathBuf { @@ -92,9 +92,9 @@ impl TryFrom<&str> for AbsPathBuf { } } -impl PartialEq<AbsPath> for AbsPathBuf { - fn eq(&self, other: &AbsPath) -> bool { - self.as_path() == other +impl<P: AsRef<Path> + ?Sized> PartialEq<P> for AbsPathBuf { + fn eq(&self, other: &P) -> bool { + self.0.as_std_path() == other.as_ref() } } @@ -144,10 +144,16 @@ impl fmt::Display for AbsPathBuf { } /// Wrapper around an absolute [`Utf8Path`]. -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash)] +#[derive(Debug, Ord, PartialOrd, Eq, Hash)] #[repr(transparent)] pub struct AbsPath(Utf8Path); +impl<P: AsRef<Path> + ?Sized> PartialEq<P> for AbsPath { + fn eq(&self, other: &P) -> bool { + self.0.as_std_path() == other.as_ref() + } +} + impl AsRef<Utf8Path> for AbsPath { fn as_ref(&self) -> &Utf8Path { &self.0 |