File tree Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Expand file tree Collapse file tree 3 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,7 @@ fn try_parsing_version(s: &str) -> Option<Version> {
143
143
let s = s. trim ( ) ;
144
144
debug ! ( "Attempting to parse: %s" , s) ;
145
145
let mut parse_state = Start ;
146
- // I gave up on using external iterators (tjc)
147
- for str:: to_chars( s) . each( ) |& c| {
146
+ for s. iter( ) . advance |& c| {
148
147
if char:: is_digit( c) {
149
148
parse_state = SawDigit ;
150
149
}
@@ -172,7 +171,7 @@ fn is_url_like(p: &RemotePath) -> bool {
172
171
/// Otherwise, return None.
173
172
pub fn split_version < ' a > ( s: & ' a str) -> Option < ( & ' a str , Version ) > {
174
173
// reject strings with multiple '#'s
175
- if { let mut i : uint = 0 ; for str :: to_chars ( s ) . each | & c| { if c == '#' { i += 1 ; } } ; i > 1 } {
174
+ if s . splitn_iter ( '#' , 2 ) . count ( ) > 1 {
176
175
return None ;
177
176
}
178
177
match s. rfind( '#' ) {
Original file line number Diff line number Diff line change @@ -432,11 +432,6 @@ pub fn byte_slice_no_callback<'a>(s: &'a str) -> &'a [u8] {
432
432
}
433
433
}
434
434
435
- /// Convert a string to a unique vector of characters
436
- pub fn to_chars ( s : & str ) -> ~[ char ] {
437
- s. iter ( ) . collect ( )
438
- }
439
-
440
435
/**
441
436
* Take a substring of another.
442
437
*
Original file line number Diff line number Diff line change 10
10
11
11
extern mod extra;
12
12
13
+ use std:: iterator:: IteratorUtil ;
13
14
use std:: str;
14
15
use std:: vec;
15
16
16
17
pub fn main ( ) {
17
18
// Chars of 1, 2, 3, and 4 bytes
18
19
let chs: ~[ char ] = ~[ 'e' , 'é' , '€' , 0x10000 as char ] ;
19
20
let s: ~str = str:: from_chars ( chs) ;
21
+ let schs: ~[ char ] = s. iter ( ) . collect ( ) ;
20
22
21
23
assert ! ( s. len( ) == 10 u) ;
22
24
assert ! ( str :: char_len( s) == 4 u) ;
23
- assert ! ( str :: to_chars ( s ) . len( ) == 4 u) ;
24
- assert ! ( str :: from_chars( str :: to_chars ( s ) ) == s) ;
25
+ assert ! ( schs . len( ) == 4 u) ;
26
+ assert ! ( str :: from_chars( schs ) == s) ;
25
27
assert ! ( s. char_at( 0 u) == 'e' ) ;
26
28
assert ! ( s. char_at( 1 u) == 'é' ) ;
27
29
You can’t perform that action at this time.
0 commit comments