@@ -2004,6 +2004,13 @@ impl AsRef<Path> for OsStr {
2004
2004
}
2005
2005
}
2006
2006
2007
+ #[ stable( feature = "cow_os_str_as_ref_path" , since = "1.8.0" ) ]
2008
+ impl < ' a > AsRef < Path > for Cow < ' a , OsStr > {
2009
+ fn as_ref ( & self ) -> & Path {
2010
+ Path :: new ( self )
2011
+ }
2012
+ }
2013
+
2007
2014
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2008
2015
impl AsRef < Path > for OsString {
2009
2016
fn as_ref ( & self ) -> & Path {
@@ -2046,7 +2053,7 @@ impl<'a> IntoIterator for &'a Path {
2046
2053
fn into_iter ( self ) -> Iter < ' a > { self . iter ( ) }
2047
2054
}
2048
2055
2049
- macro_rules! impl_eq {
2056
+ macro_rules! impl_cmp {
2050
2057
( $lhs: ty, $rhs: ty) => {
2051
2058
#[ stable( feature = "partialeq_path" , since = "1.6.0" ) ]
2052
2059
impl <' a, ' b> PartialEq <$rhs> for $lhs {
@@ -2060,14 +2067,76 @@ macro_rules! impl_eq {
2060
2067
fn eq( & self , other: & $lhs) -> bool { <Path as PartialEq >:: eq( self , other) }
2061
2068
}
2062
2069
2070
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2071
+ impl <' a, ' b> PartialOrd <$rhs> for $lhs {
2072
+ #[ inline]
2073
+ fn partial_cmp( & self , other: & $rhs) -> Option <cmp:: Ordering > {
2074
+ <Path as PartialOrd >:: partial_cmp( self , other)
2075
+ }
2076
+ }
2077
+
2078
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2079
+ impl <' a, ' b> PartialOrd <$lhs> for $rhs {
2080
+ #[ inline]
2081
+ fn partial_cmp( & self , other: & $lhs) -> Option <cmp:: Ordering > {
2082
+ <Path as PartialOrd >:: partial_cmp( self , other)
2083
+ }
2084
+ }
2085
+ }
2086
+ }
2087
+
2088
+ impl_cmp ! ( PathBuf , Path ) ;
2089
+ impl_cmp ! ( PathBuf , & ' a Path ) ;
2090
+ impl_cmp ! ( Cow <' a, Path >, Path ) ;
2091
+ impl_cmp ! ( Cow <' a, Path >, & ' b Path ) ;
2092
+ impl_cmp ! ( Cow <' a, Path >, PathBuf ) ;
2093
+
2094
+ macro_rules! impl_cmp_os_str {
2095
+ ( $lhs: ty, $rhs: ty) => {
2096
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2097
+ impl <' a, ' b> PartialEq <$rhs> for $lhs {
2098
+ #[ inline]
2099
+ fn eq( & self , other: & $rhs) -> bool { <Path as PartialEq >:: eq( self , other. as_ref( ) ) }
2100
+ }
2101
+
2102
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2103
+ impl <' a, ' b> PartialEq <$lhs> for $rhs {
2104
+ #[ inline]
2105
+ fn eq( & self , other: & $lhs) -> bool { <Path as PartialEq >:: eq( self . as_ref( ) , other) }
2106
+ }
2107
+
2108
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2109
+ impl <' a, ' b> PartialOrd <$rhs> for $lhs {
2110
+ #[ inline]
2111
+ fn partial_cmp( & self , other: & $rhs) -> Option <cmp:: Ordering > {
2112
+ <Path as PartialOrd >:: partial_cmp( self , other. as_ref( ) )
2113
+ }
2114
+ }
2115
+
2116
+ #[ stable( feature = "cmp_path" , since = "1.8.0" ) ]
2117
+ impl <' a, ' b> PartialOrd <$lhs> for $rhs {
2118
+ #[ inline]
2119
+ fn partial_cmp( & self , other: & $lhs) -> Option <cmp:: Ordering > {
2120
+ <Path as PartialOrd >:: partial_cmp( self . as_ref( ) , other)
2121
+ }
2122
+ }
2063
2123
}
2064
2124
}
2065
2125
2066
- impl_eq ! ( PathBuf , Path ) ;
2067
- impl_eq ! ( PathBuf , & ' a Path ) ;
2068
- impl_eq ! ( Cow <' a, Path >, Path ) ;
2069
- impl_eq ! ( Cow <' a, Path >, & ' b Path ) ;
2070
- impl_eq ! ( Cow <' a, Path >, PathBuf ) ;
2126
+ impl_cmp_os_str ! ( PathBuf , OsStr ) ;
2127
+ impl_cmp_os_str ! ( PathBuf , & ' a OsStr ) ;
2128
+ impl_cmp_os_str ! ( PathBuf , Cow <' a, OsStr >) ;
2129
+ impl_cmp_os_str ! ( PathBuf , OsString ) ;
2130
+ impl_cmp_os_str ! ( Path , OsStr ) ;
2131
+ impl_cmp_os_str ! ( Path , & ' a OsStr ) ;
2132
+ impl_cmp_os_str ! ( Path , Cow <' a, OsStr >) ;
2133
+ impl_cmp_os_str ! ( Path , OsString ) ;
2134
+ impl_cmp_os_str ! ( & ' a Path , OsStr ) ;
2135
+ impl_cmp_os_str ! ( & ' a Path , Cow <' b, OsStr >) ;
2136
+ impl_cmp_os_str ! ( & ' a Path , OsString ) ;
2137
+ impl_cmp_os_str ! ( Cow <' a, Path >, OsStr ) ;
2138
+ impl_cmp_os_str ! ( Cow <' a, Path >, & ' b OsStr ) ;
2139
+ impl_cmp_os_str ! ( Cow <' a, Path >, OsString ) ;
2071
2140
2072
2141
#[ stable( since = "1.7.0" , feature = "strip_prefix" ) ]
2073
2142
impl fmt:: Display for StripPrefixError {
0 commit comments