From dd284eb396d802646106bdb15f474ebc10a9dfbb Mon Sep 17 00:00:00 2001 From: Lenny222 Date: Mon, 2 Jan 2012 21:29:44 +0100 Subject: [PATCH] "char": use shorter names "to_lower"/"to_upper", analogous to the same names in "str" --- src/libcore/char.rs | 10 +++++----- src/libcore/str.rs | 4 ++-- src/test/stdtest/char.rs | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 40c4033066e..5475e695a79 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -41,7 +41,7 @@ export is_alphabetic, is_XID_start, is_XID_continue, is_lowercase, is_uppercase, is_whitespace, is_alphanumeric, - to_digit, to_lowercase, to_uppercase, maybe_digit, cmp; + to_digit, to_lower, to_upper, maybe_digit, cmp; import is_alphabetic = unicode::derived_property::Alphabetic; import is_XID_start = unicode::derived_property::XID_Start; @@ -137,13 +137,13 @@ pure fn maybe_digit(c: char) -> option::t { } /* - Function: to_lowercase + Function: to_lower Convert a char to the corresponding lower case. FIXME: works only on ASCII */ -pure fn to_lowercase(c: char) -> char { +pure fn to_lower(c: char) -> char { alt c { 'A' to 'Z' { ((c as u8) + 32u8) as char } _ { c } @@ -151,13 +151,13 @@ pure fn to_lowercase(c: char) -> char { } /* - Function: to_uppercase + Function: to_upper Convert a char to the corresponding upper case. FIXME: works only on ASCII */ -pure fn to_uppercase(c: char) -> char { +pure fn to_upper(c: char) -> char { alt c { 'a' to 'z' { ((c as u8) - 32u8) as char } _ { c } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index de29f297192..1872d0ae674 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -833,7 +833,7 @@ Convert a string to lowercase fn to_lower(s: str) -> str { let outstr = ""; iter_chars(s) { |c| - push_char(outstr, char::to_lowercase(c)); + push_char(outstr, char::to_lower(c)); } ret outstr; } @@ -845,7 +845,7 @@ Convert a string to uppercase fn to_upper(s: str) -> str { let outstr = ""; iter_chars(s) { |c| - push_char(outstr, char::to_uppercase(c)); + push_char(outstr, char::to_upper(c)); } ret outstr; } diff --git a/src/test/stdtest/char.rs b/src/test/stdtest/char.rs index 23101ee34bd..7da2443d6c2 100644 --- a/src/test/stdtest/char.rs +++ b/src/test/stdtest/char.rs @@ -62,17 +62,17 @@ fn test_to_digit_fail_2() { } #[test] -fn test_to_lowercase() { - assert (char::to_lowercase('H') == 'h'); - assert (char::to_lowercase('e') == 'e'); - //assert (char::to_lowercase('Ö') == 'ö'); - assert (char::to_lowercase('ß') == 'ß'); +fn test_to_lower() { + assert (char::to_lower('H') == 'h'); + assert (char::to_lower('e') == 'e'); + //assert (char::to_lower('Ö') == 'ö'); + assert (char::to_lower('ß') == 'ß'); } #[test] -fn test_to_uppercase() { - assert (char::to_uppercase('l') == 'L'); - assert (char::to_uppercase('Q') == 'Q'); - //assert (char::to_uppercase('ü') == 'Ü'); - assert (char::to_uppercase('ß') == 'ß'); +fn test_to_upper() { + assert (char::to_upper('l') == 'L'); + assert (char::to_upper('Q') == 'Q'); + //assert (char::to_upper('ü') == 'Ü'); + assert (char::to_upper('ß') == 'ß'); }