@@ -1194,8 +1194,8 @@ pub fn with_capacity(capacity: uint) -> ~str {
1194
1194
* The number of Unicode characters in `s` between the given indices.
1195
1195
*/
1196
1196
pub fn count_chars( s: & str , start : uint , end : uint ) -> uint {
1197
- assert ! ( is_char_boundary( s , start) ) ;
1198
- assert ! ( is_char_boundary( s , end) ) ;
1197
+ assert ! ( s . is_char_boundary( start) ) ;
1198
+ assert ! ( s . is_char_boundary( end) ) ;
1199
1199
let mut ( i, len) = ( start, 0 u) ;
1200
1200
while i < end {
1201
1201
let next = s. char_range_at ( i) . next ;
@@ -1208,7 +1208,7 @@ pub fn count_chars(s: &str, start: uint, end: uint) -> uint {
1208
1208
/// Counts the number of bytes taken by the first `n` chars in `s`
1209
1209
/// starting from `start`.
1210
1210
pub fn count_bytes < ' b > ( s : & ' b str , start : uint , n : uint ) -> uint {
1211
- assert ! ( is_char_boundary( s , start) ) ;
1211
+ assert ! ( s . is_char_boundary( start) ) ;
1212
1212
let mut ( end, cnt) = ( start, n) ;
1213
1213
let l = s. len ( ) ;
1214
1214
while cnt > 0 u {
@@ -1658,7 +1658,7 @@ pub trait StrSlice<'self> {
1658
1658
fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str;
1659
1659
fn to_owned(&self) -> ~str;
1660
1660
fn to_managed(&self) -> @str;
1661
- fn is_char_boundary(s: &str , index: uint) -> bool;
1661
+ fn is_char_boundary(&self , index: uint) -> bool;
1662
1662
fn char_range_at(&self, start: uint) -> CharRange;
1663
1663
fn char_at(&self, i: uint) -> char;
1664
1664
fn char_range_at_reverse(&self, start: uint) -> CharRange;
@@ -1800,8 +1800,8 @@ impl<'self> StrSlice<'self> for &'self str {
1800
1800
*/
1801
1801
#[inline]
1802
1802
fn slice(&self, begin: uint, end: uint) -> &'self str {
1803
- assert!(is_char_boundary(*self, begin));
1804
- assert!(is_char_boundary(*self, end));
1803
+ assert!(self. is_char_boundary(begin));
1804
+ assert!(self. is_char_boundary(end));
1805
1805
unsafe { raw::slice_bytes(*self, begin, end) }
1806
1806
}
1807
1807
#[inline]
@@ -2284,7 +2284,7 @@ impl<'self> Iterator<char> for StrCharIterator<'self> {
2284
2284
#[inline]
2285
2285
fn next(&mut self) -> Option<char> {
2286
2286
if self.index < self.string.len() {
2287
- let CharRange {ch, next} = char_range_at( self.string, self.index);
2287
+ let CharRange {ch, next} = self.string.char_range_at( self.index);
2288
2288
self.index = next;
2289
2289
Some(ch)
2290
2290
} else {
@@ -2303,7 +2303,7 @@ impl<'self> Iterator<char> for StrCharRevIterator<'self> {
2303
2303
#[inline]
2304
2304
fn next(&mut self) -> Option<char> {
2305
2305
if self.index > 0 {
2306
- let CharRange {ch, next} = char_range_at_reverse( self.string, self.index);
2306
+ let CharRange {ch, next} = self.string.char_range_at_reverse( self.index);
2307
2307
self.index = next;
2308
2308
Some(ch)
2309
2309
} else {
@@ -2461,7 +2461,7 @@ mod tests {
2461
2461
2462
2462
let data = " abcabc";
2463
2463
assert_eq!(data.slice(0u, 6u).find_str(" ab"), Some(0u));
2464
- assert_eq!(data.slice(2u, 6u).find_str(" ab"), Some(3u));
2464
+ assert_eq!(data.slice(2u, 6u).find_str(" ab"), Some(3u - 2u ));
2465
2465
assert!(data.slice(2u, 4u).find_str(" ab").is_none());
2466
2466
2467
2467
let mut data = ~" ประเทศไทย中华Việt Nam ";
@@ -3042,10 +3042,10 @@ mod tests {
3042
3042
3043
3043
#[test]
3044
3044
fn test_contains_char() {
3045
- assert!(contains_char( " abc", 'b'));
3046
- assert!(contains_char( " a", 'a'));
3047
- assert!(!contains_char( " abc", 'd'));
3048
- assert!(!contains_char(" ", 'a'));
3045
+ assert!(" abc".contains_char( 'b'));
3046
+ assert!(" a".contains_char( 'a'));
3047
+ assert!(!" abc".contains_char( 'd'));
3048
+ assert!(!" ".contains_char( 'a'));
3049
3049
}
3050
3050
3051
3051
#[test]
0 commit comments