@@ -1909,6 +1909,29 @@ impl<'a> IntoIterator for &'a Path {
1909
1909
fn into_iter ( self ) -> Iter < ' a > { self . iter ( ) }
1910
1910
}
1911
1911
1912
+ macro_rules! impl_eq {
1913
+ ( $lhs: ty, $rhs: ty) => {
1914
+ #[ stable( feature = "partialeq_path" , since = "1.6.0" ) ]
1915
+ impl <' a, ' b> PartialEq <$rhs> for $lhs {
1916
+ #[ inline]
1917
+ fn eq( & self , other: & $rhs) -> bool { <Path as PartialEq >:: eq( self , other) }
1918
+ }
1919
+
1920
+ #[ stable( feature = "partialeq_path" , since = "1.6.0" ) ]
1921
+ impl <' a, ' b> PartialEq <$lhs> for $rhs {
1922
+ #[ inline]
1923
+ fn eq( & self , other: & $lhs) -> bool { <Path as PartialEq >:: eq( self , other) }
1924
+ }
1925
+
1926
+ }
1927
+ }
1928
+
1929
+ impl_eq ! ( PathBuf , Path ) ;
1930
+ impl_eq ! ( PathBuf , & ' a Path ) ;
1931
+ impl_eq ! ( Cow <' a, Path >, Path ) ;
1932
+ impl_eq ! ( Cow <' a, Path >, & ' b Path ) ;
1933
+ impl_eq ! ( Cow <' a, Path >, PathBuf ) ;
1934
+
1912
1935
#[ cfg( test) ]
1913
1936
mod tests {
1914
1937
use super :: * ;
@@ -3106,6 +3129,31 @@ mod tests {
3106
3129
tfe ! ( "/" , "foo" , "/" , false ) ;
3107
3130
}
3108
3131
3132
+ #[ test]
3133
+ fn test_eq_recievers ( ) {
3134
+ use borrow:: Cow ;
3135
+
3136
+ let borrowed: & Path = Path :: new ( "foo/bar" ) ;
3137
+ let mut owned: PathBuf = PathBuf :: new ( ) ;
3138
+ owned. push ( "foo" ) ;
3139
+ owned. push ( "bar" ) ;
3140
+ let borrowed_cow: Cow < Path > = borrowed. into ( ) ;
3141
+ let owned_cow: Cow < Path > = owned. clone ( ) . into ( ) ;
3142
+
3143
+ macro_rules! t {
3144
+ ( $( $current: expr) ,+) => {
3145
+ $(
3146
+ assert_eq!( $current, borrowed) ;
3147
+ assert_eq!( $current, owned) ;
3148
+ assert_eq!( $current, borrowed_cow) ;
3149
+ assert_eq!( $current, owned_cow) ;
3150
+ ) +
3151
+ }
3152
+ }
3153
+
3154
+ t ! ( borrowed, owned, borrowed_cow, owned_cow) ;
3155
+ }
3156
+
3109
3157
#[ test]
3110
3158
pub fn test_compare ( ) {
3111
3159
use hash:: { Hash , Hasher , SipHasher } ;
0 commit comments