diff options
| author | Gleb Kozyrev <gleb@gkoz.com> | 2016-02-18 16:08:30 +0200 |
|---|---|---|
| committer | Gleb Kozyrev <gleb@gkoz.com> | 2016-02-18 16:08:30 +0200 |
| commit | 409bffa6545ffb760403a82f5fb27678ad2a0aca (patch) | |
| tree | 63b3c348e9c2ef83799b8bba750b91e1d61c882a /src | |
| parent | ccad5449ff11b07368a30a7d843cc6ce57fdd0aa (diff) | |
| download | rust-409bffa6545ffb760403a82f5fb27678ad2a0aca.tar.gz rust-409bffa6545ffb760403a82f5fb27678ad2a0aca.zip | |
Add mutual PartialEq and PartialOrd impls for Path[Buf] and OsStr[ing]
Diffstat (limited to 'src')
| -rw-r--r-- | src/libstd/path.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 887de66a1bd..8236af406b7 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2089,6 +2089,53 @@ impl_cmp!(Cow<'a, Path>, Path); impl_cmp!(Cow<'a, Path>, &'b Path); impl_cmp!(Cow<'a, Path>, PathBuf); +macro_rules! impl_cmp_os_str { + ($lhs:ty, $rhs: ty) => { + #[stable(feature = "cmp_path", since = "1.8.0")] + impl<'a, 'b> PartialEq<$rhs> for $lhs { + #[inline] + fn eq(&self, other: &$rhs) -> bool { <Path as PartialEq>::eq(self, other.as_ref()) } + } + + #[stable(feature = "cmp_path", since = "1.8.0")] + impl<'a, 'b> PartialEq<$lhs> for $rhs { + #[inline] + fn eq(&self, other: &$lhs) -> bool { <Path as PartialEq>::eq(self.as_ref(), other) } + } + + #[stable(feature = "cmp_path", since = "1.8.0")] + impl<'a, 'b> PartialOrd<$rhs> for $lhs { + #[inline] + fn partial_cmp(&self, other: &$rhs) -> Option<cmp::Ordering> { + <Path as PartialOrd>::partial_cmp(self, other.as_ref()) + } + } + + #[stable(feature = "cmp_path", since = "1.8.0")] + impl<'a, 'b> PartialOrd<$lhs> for $rhs { + #[inline] + fn partial_cmp(&self, other: &$lhs) -> Option<cmp::Ordering> { + <Path as PartialOrd>::partial_cmp(self.as_ref(), other) + } + } + } +} + +impl_cmp_os_str!(PathBuf, OsStr); +impl_cmp_os_str!(PathBuf, &'a OsStr); +impl_cmp_os_str!(PathBuf, Cow<'a, OsStr>); +impl_cmp_os_str!(PathBuf, OsString); +impl_cmp_os_str!(Path, OsStr); +impl_cmp_os_str!(Path, &'a OsStr); +impl_cmp_os_str!(Path, Cow<'a, OsStr>); +impl_cmp_os_str!(Path, OsString); +impl_cmp_os_str!(&'a Path, OsStr); +impl_cmp_os_str!(&'a Path, Cow<'b, OsStr>); +impl_cmp_os_str!(&'a Path, OsString); +impl_cmp_os_str!(Cow<'a, Path>, OsStr); +impl_cmp_os_str!(Cow<'a, Path>, &'b OsStr); +impl_cmp_os_str!(Cow<'a, Path>, OsString); + #[stable(since = "1.7.0", feature = "strip_prefix")] impl fmt::Display for StripPrefixError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
