@@ -1743,7 +1743,7 @@ impl<'a> StrSlice<'a> for &'a str {
17431743 fn lines_any ( & self ) -> AnyLines < ' a > {
17441744 self . lines ( ) . map ( |line| {
17451745 let l = line. len ( ) ;
1746- if l > 0 && line[ l - 1 ] == '\r' as u8 { line. slice ( 0 , l - 1 ) }
1746+ if l > 0 && line. as_bytes ( ) [ l - 1 ] == '\r' as u8 { line. slice ( 0 , l - 1 ) }
17471747 else { line }
17481748 } )
17491749 }
@@ -1867,26 +1867,26 @@ impl<'a> StrSlice<'a> for &'a str {
18671867 fn is_char_boundary ( & self , index : uint ) -> bool {
18681868 if index == self . len ( ) { return true ; }
18691869 if index > self . len ( ) { return false ; }
1870- let b = self [ index] ;
1870+ let b = self . as_bytes ( ) [ index] ;
18711871 return b < 128u8 || b >= 192u8 ;
18721872 }
18731873
18741874 #[ inline]
18751875 fn char_range_at ( & self , i : uint ) -> CharRange {
1876- if self [ i] < 128u8 {
1877- return CharRange { ch : self [ i] as char , next : i + 1 } ;
1876+ if self . as_bytes ( ) [ i] < 128u8 {
1877+ return CharRange { ch : self . as_bytes ( ) [ i] as char , next : i + 1 } ;
18781878 }
18791879
18801880 // Multibyte case is a fn to allow char_range_at to inline cleanly
18811881 fn multibyte_char_range_at ( s : & str , i : uint ) -> CharRange {
1882- let mut val = s[ i] as u32 ;
1882+ let mut val = s. as_bytes ( ) [ i] as u32 ;
18831883 let w = UTF8_CHAR_WIDTH [ val as uint ] as uint ;
18841884 assert ! ( ( w != 0 ) ) ;
18851885
18861886 val = utf8_first_byte ! ( val, w) ;
1887- val = utf8_acc_cont_byte ! ( val, s[ i + 1 ] ) ;
1888- if w > 2 { val = utf8_acc_cont_byte ! ( val, s[ i + 2 ] ) ; }
1889- if w > 3 { val = utf8_acc_cont_byte ! ( val, s[ i + 3 ] ) ; }
1887+ val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 1 ] ) ;
1888+ if w > 2 { val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 2 ] ) ; }
1889+ if w > 3 { val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 3 ] ) ; }
18901890
18911891 return CharRange { ch : unsafe { mem:: transmute ( val) } , next : i + w} ;
18921892 }
@@ -1899,23 +1899,25 @@ impl<'a> StrSlice<'a> for &'a str {
18991899 let mut prev = start;
19001900
19011901 prev = prev. saturating_sub ( 1 ) ;
1902- if self [ prev] < 128 { return CharRange { ch : self [ prev] as char , next : prev} }
1902+ if self . as_bytes ( ) [ prev] < 128 {
1903+ return CharRange { ch : self . as_bytes ( ) [ prev] as char , next : prev}
1904+ }
19031905
19041906 // Multibyte case is a fn to allow char_range_at_reverse to inline cleanly
19051907 fn multibyte_char_range_at_reverse ( s : & str , mut i : uint ) -> CharRange {
19061908 // while there is a previous byte == 10......
1907- while i > 0 && s[ i] & 192u8 == TAG_CONT_U8 {
1909+ while i > 0 && s. as_bytes ( ) [ i] & 192u8 == TAG_CONT_U8 {
19081910 i -= 1 u;
19091911 }
19101912
1911- let mut val = s[ i] as u32 ;
1913+ let mut val = s. as_bytes ( ) [ i] as u32 ;
19121914 let w = UTF8_CHAR_WIDTH [ val as uint ] as uint ;
19131915 assert ! ( ( w != 0 ) ) ;
19141916
19151917 val = utf8_first_byte ! ( val, w) ;
1916- val = utf8_acc_cont_byte ! ( val, s[ i + 1 ] ) ;
1917- if w > 2 { val = utf8_acc_cont_byte ! ( val, s[ i + 2 ] ) ; }
1918- if w > 3 { val = utf8_acc_cont_byte ! ( val, s[ i + 3 ] ) ; }
1918+ val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 1 ] ) ;
1919+ if w > 2 { val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 2 ] ) ; }
1920+ if w > 3 { val = utf8_acc_cont_byte ! ( val, s. as_bytes ( ) [ i + 3 ] ) ; }
19191921
19201922 return CharRange { ch : unsafe { mem:: transmute ( val) } , next : i} ;
19211923 }
0 commit comments