1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
//! Implementations of comparison traits copied and modified from The Rust
//! Programming Language.
//!
//! Sources:
//! - <https://github.com/rust-lang/rust/blob/b1277d04db0dc8009037e872a1be7cdc2bd74a43/library/std/src/path.rs#L2635-L2726>
//!
//! Copyrights:
//! - Copyrights in the Rust project are retained by their contributors. No
//! copyright assignment is required to contribute to the Rust project.
//!
//! Some files include explicit copyright notices and/or license notices.
//! For full authorship information, see the version control history or
//! <https://thanks.rust-lang.org>
//!
//! <https://github.com/rust-lang/rust/blob/b1277d04db0dc8009037e872a1be7cdc2bd74a43/COPYRIGHT>
//! - Modifications copyright (c) 2020 dylni (<https://github.com/dylni>)<br>
//! <https://github.com/dylni/normpath/blob/master/COPYRIGHT>
use std::borrow::Cow;
use std::cmp::Ordering;
use std::path::Path;
use std::path::PathBuf;
use super::BasePath;
use super::BasePathBuf;
macro_rules! r#impl {
( $left:ty , $right:ty ) => {
impl PartialEq<$right> for $left {
#[inline]
fn eq(&self, other: &$right) -> bool {
<BasePath as PartialEq<Path>>::eq(self, other.as_ref())
}
}
impl PartialEq<$left> for $right {
#[inline]
fn eq(&self, other: &$left) -> bool {
other == self
}
}
impl PartialOrd<$right> for $left {
#[inline]
fn partial_cmp(&self, other: &$right) -> Option<Ordering> {
<BasePath as PartialOrd<Path>>::partial_cmp(
self,
other.as_ref(),
)
}
}
impl PartialOrd<$left> for $right {
#[inline]
fn partial_cmp(&self, other: &$left) -> Option<Ordering> {
other.partial_cmp(self)
}
}
};
}
r#impl!(BasePathBuf, BasePath);
r#impl!(BasePathBuf, &BasePath);
r#impl!(Cow<'_, BasePath>, BasePath);
r#impl!(Cow<'_, BasePath>, &BasePath);
r#impl!(Cow<'_, BasePath>, BasePathBuf);
r#impl!(BasePathBuf, Path);
r#impl!(BasePathBuf, &Path);
r#impl!(BasePathBuf, Cow<'_, Path>);
r#impl!(BasePathBuf, PathBuf);
r#impl!(BasePath, &Path);
r#impl!(BasePath, Cow<'_, Path>);
r#impl!(BasePath, PathBuf);
r#impl!(&BasePath, Path);
r#impl!(&BasePath, Cow<'_, Path>);
r#impl!(&BasePath, PathBuf);