Skip to content

Commit 76ae315

Browse files
killerswanbrson
authored andcommitted
---
yaml --- r: 10931 b: refs/heads/master c: 1f795ff h: refs/heads/master i: 10929: 3f63d5a 10927: b89f49d v: v3
1 parent 81d0bb8 commit 76ae315

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: a8b657397aa9cd4b85ef68cc11b5ce48ee99d3ce
2+
refs/heads/master: 1f795ff3b0c0cac31c1d9fd2406d0d53e774683a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/libcore/str.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -674,30 +674,18 @@ fn windowed(nn: uint, ss: str) -> [str] {
674674
Function: to_lower
675675
676676
Convert a string to lowercase
677-
678-
FIXME: rewrite with map
679677
*/
680678
fn to_lower(s: str) -> str {
681-
let outstr = "";
682-
chars_iter(s) { |c|
683-
push_char(outstr, char::to_lower(c));
684-
}
685-
ret outstr;
679+
map(s, char::to_lower)
686680
}
687681

688682
/*
689683
Function: to_upper
690684
691685
Convert a string to uppercase
692-
693-
FIXME: rewrite with map
694686
*/
695687
fn to_upper(s: str) -> str {
696-
let outstr = "";
697-
chars_iter(s) { |c|
698-
push_char(outstr, char::to_upper(c));
699-
}
700-
ret outstr;
688+
map(s, char::to_upper)
701689
}
702690

703691
// FIXME: This is super-inefficient
@@ -1583,8 +1571,9 @@ mod tests {
15831571

15841572
#[test]
15851573
fn test_to_upper() {
1586-
// to_upper doesn't understand unicode yet,
1587-
// but we need to at least preserve it
1574+
// char::to_upper, and hence str::to_upper
1575+
// are culturally insensitive: I'm not sure they
1576+
// really work for anything but English ASCII, but YMMV
15881577

15891578
let unicode = "\u65e5\u672c";
15901579
let input = "abcDEF" + unicode + "xyz:.;";
@@ -1593,6 +1582,12 @@ mod tests {
15931582
assert (eq(expected, actual));
15941583
}
15951584

1585+
#[test]
1586+
fn test_to_lower() {
1587+
assert "" == map("", char::to_lower);
1588+
assert "ymca" == map("YMCA", char::to_lower);
1589+
}
1590+
15961591
#[test]
15971592
fn test_slice() {
15981593
assert (eq("ab", slice("abc", 0u, 2u)));

0 commit comments

Comments
 (0)