Skip to content

Commit 460d2a9

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 13934 b: refs/heads/try c: c7454f5 h: refs/heads/master v: v3
1 parent 5790b79 commit 460d2a9

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 685a434e0a4b432125feda745e4c4d034dc74245
5+
refs/heads/try: c7454f55959584579dc982d38c8432e84c7f8900
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/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
}

branches/try/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)