@@ -675,14 +675,6 @@ impl OsStr {
675
675
let boxed = unsafe { Box :: from_raw ( Box :: into_raw ( self ) as * mut Slice ) } ;
676
676
OsString { inner : Buf :: from_box ( boxed) }
677
677
}
678
-
679
- /// Gets the underlying byte representation.
680
- ///
681
- /// Note: it is *crucial* that this API is private, to avoid
682
- /// revealing the internal, platform-specific encodings.
683
- fn bytes ( & self ) -> & [ u8 ] {
684
- unsafe { & * ( & self . inner as * const _ as * const [ u8 ] ) }
685
- }
686
678
}
687
679
688
680
#[ stable( feature = "box_from_os_str" , since = "1.17.0" ) ]
@@ -819,7 +811,7 @@ impl Default for &OsStr {
819
811
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
820
812
impl PartialEq for OsStr {
821
813
fn eq ( & self , other : & OsStr ) -> bool {
822
- self . bytes ( ) . eq ( other. bytes ( ) )
814
+ self . inner == other. inner
823
815
}
824
816
}
825
817
@@ -844,16 +836,16 @@ impl Eq for OsStr {}
844
836
impl PartialOrd for OsStr {
845
837
#[ inline]
846
838
fn partial_cmp ( & self , other : & OsStr ) -> Option < cmp:: Ordering > {
847
- self . bytes ( ) . partial_cmp ( other. bytes ( ) )
839
+ self . inner . partial_cmp ( & other. inner )
848
840
}
849
841
#[ inline]
850
- fn lt ( & self , other : & OsStr ) -> bool { self . bytes ( ) . lt ( other. bytes ( ) ) }
842
+ fn lt ( & self , other : & OsStr ) -> bool { self . inner < other. inner }
851
843
#[ inline]
852
- fn le ( & self , other : & OsStr ) -> bool { self . bytes ( ) . le ( other. bytes ( ) ) }
844
+ fn le ( & self , other : & OsStr ) -> bool { self . inner <= other. inner }
853
845
#[ inline]
854
- fn gt ( & self , other : & OsStr ) -> bool { self . bytes ( ) . gt ( other. bytes ( ) ) }
846
+ fn gt ( & self , other : & OsStr ) -> bool { self . inner > other. inner }
855
847
#[ inline]
856
- fn ge ( & self , other : & OsStr ) -> bool { self . bytes ( ) . ge ( other. bytes ( ) ) }
848
+ fn ge ( & self , other : & OsStr ) -> bool { self . inner >= other. inner }
857
849
}
858
850
859
851
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -870,7 +862,7 @@ impl PartialOrd<str> for OsStr {
870
862
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
871
863
impl Ord for OsStr {
872
864
#[ inline]
873
- fn cmp ( & self , other : & OsStr ) -> cmp:: Ordering { self . bytes ( ) . cmp ( other. bytes ( ) ) }
865
+ fn cmp ( & self , other : & OsStr ) -> cmp:: Ordering { self . inner . cmp ( & other. inner ) }
874
866
}
875
867
876
868
macro_rules! impl_cmp {
@@ -915,7 +907,7 @@ impl_cmp!(Cow<'a, OsStr>, OsString);
915
907
impl Hash for OsStr {
916
908
#[ inline]
917
909
fn hash < H : Hasher > ( & self , state : & mut H ) {
918
- self . bytes ( ) . hash ( state)
910
+ self . inner . hash ( state)
919
911
}
920
912
}
921
913
0 commit comments