64
64
any,
65
65
map,
66
66
bytes_iter,
67
- iter_chars,
68
67
chars_iter,
69
68
words_iter,
70
69
lines_iter,
@@ -591,7 +590,7 @@ fn split_func(ss: str, sepfn: fn(cc: char)->bool) -> [str] {
591
590
let accum: str = "" ;
592
591
let ends_with_sep: bool = false ;
593
592
594
- str :: iter_chars ( ss, { |cc| if sepfn ( cc) {
593
+ chars_iter ( ss, { |cc| if sepfn ( cc) {
595
594
vv += [ accum] ;
596
595
accum = "" ;
597
596
ends_with_sep = true ;
@@ -678,7 +677,7 @@ FIXME: rewrite with map
678
677
*/
679
678
fn to_lower ( s : str ) -> str {
680
679
let outstr = "" ;
681
- iter_chars ( s) { |c|
680
+ chars_iter ( s) { |c|
682
681
push_char ( outstr, char:: to_lower ( c) ) ;
683
682
}
684
683
ret outstr;
@@ -693,7 +692,7 @@ FIXME: rewrite with map
693
692
*/
694
693
fn to_upper ( s : str ) -> str {
695
694
let outstr = "" ;
696
- iter_chars ( s) { |c|
695
+ chars_iter ( s) { |c|
697
696
push_char ( outstr, char:: to_upper ( c) ) ;
698
697
}
699
698
ret outstr;
@@ -808,7 +807,7 @@ Apply a function to each character
808
807
fn map ( ss : str , ff : fn ( char ) -> char ) -> str {
809
808
let result = "" ;
810
809
811
- str :: iter_chars ( ss, { |cc|
810
+ chars_iter ( ss, { |cc|
812
811
str:: push_char ( result, ff ( cc) ) ;
813
812
} ) ;
814
813
@@ -833,13 +832,11 @@ fn bytes_iter(ss: str, it: fn(u8)) {
833
832
}
834
833
835
834
/*
836
- Function: iter_chars
835
+ Function: chars_iter
837
836
838
837
Iterate over the characters in a string
839
-
840
- FIXME: rename to 'chars_iter'
841
838
*/
842
- fn iter_chars ( s : str , it : fn ( char ) ) {
839
+ fn chars_iter ( s : str , it : fn ( char ) ) {
843
840
let pos = 0 u, len = byte_len ( s) ;
844
841
while ( pos < len) {
845
842
let { ch, next} = char_range_at ( s, pos) ;
@@ -848,17 +845,6 @@ fn iter_chars(s: str, it: fn(char)) {
848
845
}
849
846
}
850
847
851
- /*
852
- Function: chars_iter
853
-
854
- Iterate over the characters in a string
855
-
856
- FIXME: A synonym to iter_chars
857
- */
858
- fn chars_iter ( ss : str , it : fn ( char ) ) {
859
- iter_chars ( ss, it)
860
- }
861
-
862
848
/*
863
849
Function: words_iter
864
850
@@ -1845,21 +1831,6 @@ mod tests {
1845
1831
assert ! contains( "" , "a" ) ;
1846
1832
}
1847
1833
1848
- #[ test]
1849
- fn test_iter_chars ( ) {
1850
- let i = 0 ;
1851
- iter_chars ( "x\u03c0 y" ) { |ch|
1852
- alt i {
1853
- 0 { assert ch == 'x' ; }
1854
- 1 { assert ch == '\u03c0' ; }
1855
- 2 { assert ch == 'y' ; }
1856
- }
1857
- i += 1 ;
1858
- }
1859
-
1860
- iter_chars ( "" ) { |_ch| fail; } // should not fail
1861
- }
1862
-
1863
1834
#[ test]
1864
1835
fn test_chars_iter ( ) {
1865
1836
let i = 0 ;
0 commit comments