Skip to content

Commit c7454f5

Browse files
killerswanbrson
authored andcommitted
Rename str::to_chars -> str::chars
1 parent 685a434 commit c7454f5

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/libcore/str.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export
3535

3636
// Transforming strings
3737
bytes,
38-
to_chars,
38+
chars,
3939
substr,
4040
char_slice,
4141
slice,
@@ -341,7 +341,7 @@ fn trim_left(s: str) -> str {
341341
}
342342
ret i;
343343
}
344-
let chars = to_chars(s);
344+
let chars = chars(s);
345345
let whities = count_whities(chars);
346346
ret from_chars(vec::slice(chars, whities, vec::len(chars)));
347347
}
@@ -360,7 +360,7 @@ fn trim_right(s: str) -> str {
360360
}
361361
ret i;
362362
}
363-
let chars = to_chars(s);
363+
let chars = chars(s);
364364
let whities = count_whities(chars);
365365
ret from_chars(vec::slice(chars, 0u, whities));
366366
}
@@ -391,13 +391,13 @@ fn bytes(s: str) -> [u8] unsafe {
391391
}
392392

393393
/*
394-
Function: to_chars
394+
Function: chars
395395
396396
Convert a string to a vector of characters
397397
398398
FIXME: rename to 'chars'
399399
*/
400-
fn to_chars(s: str) -> [char] {
400+
fn chars(s: str) -> [char] {
401401
let buf: [char] = [];
402402
let i = 0u;
403403
let len = byte_len(s);
@@ -440,7 +440,7 @@ Failure:
440440
FIXME: rename to slice(), make faster by avoiding char conversion
441441
*/
442442
fn char_slice(s: str, begin: uint, end: uint) -> str {
443-
from_chars(vec::slice(to_chars(s), begin, end))
443+
from_chars(vec::slice(chars(s), begin, end))
444444
}
445445

446446
/*
@@ -1978,4 +1978,11 @@ mod tests {
19781978
fn test_windowed_() {
19791979
let _x = windowed(0u, "abcd");
19801980
}
1981+
1982+
#[test]
1983+
fn test_chars() {
1984+
let ss = "ศไทย中华Việt Nam";
1985+
assert ['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']
1986+
== chars(ss);
1987+
}
19811988
}

src/test/run-pass/utf8_chars.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ fn main() {
99

1010
assert (str::byte_len(s) == 10u);
1111
assert (str::char_len(s) == 4u);
12-
assert (vec::len::<char>(str::to_chars(s)) == 4u);
13-
assert (str::eq(str::from_chars(str::to_chars(s)), s));
12+
assert (vec::len::<char>(str::chars(s)) == 4u);
13+
assert (str::eq(str::from_chars(str::chars(s)), s));
1414
assert (str::char_at(s, 0u) == 'e');
1515
assert (str::char_at(s, 1u) == 'é');
1616

0 commit comments

Comments
 (0)