Add mutual PartialEq and PartialCmp impls for OsStr, OsString
This commit is contained in:
parent
b54770c245
commit
9fb4fcac82
1 changed files with 38 additions and 0 deletions
|
|
@ -343,6 +343,44 @@ impl Ord for OsStr {
|
|||
fn cmp(&self, other: &OsStr) -> cmp::Ordering { self.bytes().cmp(other.bytes()) }
|
||||
}
|
||||
|
||||
macro_rules! impl_cmp {
|
||||
($lhs:ty, $rhs: ty) => {
|
||||
#[stable(feature = "cmp_os_str", since = "1.8.0")]
|
||||
impl<'a, 'b> PartialEq<$rhs> for $lhs {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$rhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
|
||||
}
|
||||
|
||||
#[stable(feature = "cmp_os_str", since = "1.8.0")]
|
||||
impl<'a, 'b> PartialEq<$lhs> for $rhs {
|
||||
#[inline]
|
||||
fn eq(&self, other: &$lhs) -> bool { <OsStr as PartialEq>::eq(self, other) }
|
||||
}
|
||||
|
||||
#[stable(feature = "cmp_os_str", since = "1.8.0")]
|
||||
impl<'a, 'b> PartialOrd<$rhs> for $lhs {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &$rhs) -> Option<cmp::Ordering> {
|
||||
<OsStr as PartialOrd>::partial_cmp(self, other)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "cmp_os_str", since = "1.8.0")]
|
||||
impl<'a, 'b> PartialOrd<$lhs> for $rhs {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &$lhs) -> Option<cmp::Ordering> {
|
||||
<OsStr as PartialOrd>::partial_cmp(self, other)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl_cmp!(OsString, OsStr);
|
||||
impl_cmp!(OsString, &'a OsStr);
|
||||
impl_cmp!(Cow<'a, OsStr>, OsStr);
|
||||
impl_cmp!(Cow<'a, OsStr>, &'b OsStr);
|
||||
impl_cmp!(Cow<'a, OsStr>, OsString);
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl Hash for OsStr {
|
||||
#[inline]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue