@@ -343,6 +343,44 @@ impl Ord for OsStr {
343343 fn cmp ( & self , other : & OsStr ) -> cmp:: Ordering { self . bytes ( ) . cmp ( other. bytes ( ) ) }
344344}
345345
346+ macro_rules! impl_cmp {
347+ ( $lhs: ty, $rhs: ty) => {
348+ #[ stable( feature = "cmp_os_str" , since = "1.8.0" ) ]
349+ impl <' a, ' b> PartialEq <$rhs> for $lhs {
350+ #[ inline]
351+ fn eq( & self , other: & $rhs) -> bool { <OsStr as PartialEq >:: eq( self , other) }
352+ }
353+
354+ #[ stable( feature = "cmp_os_str" , since = "1.8.0" ) ]
355+ impl <' a, ' b> PartialEq <$lhs> for $rhs {
356+ #[ inline]
357+ fn eq( & self , other: & $lhs) -> bool { <OsStr as PartialEq >:: eq( self , other) }
358+ }
359+
360+ #[ stable( feature = "cmp_os_str" , since = "1.8.0" ) ]
361+ impl <' a, ' b> PartialOrd <$rhs> for $lhs {
362+ #[ inline]
363+ fn partial_cmp( & self , other: & $rhs) -> Option <cmp:: Ordering > {
364+ <OsStr as PartialOrd >:: partial_cmp( self , other)
365+ }
366+ }
367+
368+ #[ stable( feature = "cmp_os_str" , since = "1.8.0" ) ]
369+ impl <' a, ' b> PartialOrd <$lhs> for $rhs {
370+ #[ inline]
371+ fn partial_cmp( & self , other: & $lhs) -> Option <cmp:: Ordering > {
372+ <OsStr as PartialOrd >:: partial_cmp( self , other)
373+ }
374+ }
375+ }
376+ }
377+
378+ impl_cmp ! ( OsString , OsStr ) ;
379+ impl_cmp ! ( OsString , & ' a OsStr ) ;
380+ impl_cmp ! ( Cow <' a, OsStr >, OsStr ) ;
381+ impl_cmp ! ( Cow <' a, OsStr >, & ' b OsStr ) ;
382+ impl_cmp ! ( Cow <' a, OsStr >, OsString ) ;
383+
346384#[ stable( feature = "rust1" , since = "1.0.0" ) ]
347385impl Hash for OsStr {
348386 #[ inline]
0 commit comments