Skip to content

Commit bb55b2c

Browse files
committed
---
yaml --- r: 6981 b: refs/heads/master c: eba891e h: refs/heads/master i: 6979: 55d474a v: v3
1 parent 8e08d81 commit bb55b2c

File tree

5 files changed

+19
-64
lines changed

5 files changed

+19
-64
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: f8d7a1c2586ad1fda7358b445114c02b048149f5
2+
refs/heads/master: eba891e989bd8e051e853b1760824013ce23da3a

trunk/doc/tutorial/args.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ Another style is by-move, which will cause the argument to become
104104
de-initialized on the caller side, and give ownership of it to the
105105
called function. This is written `-`.
106106

107+
Sometimes you need to pass a structural type by value, such as when
108+
interfacing with external native functions. This is written `++`.
109+
107110
Finally, the default passing styles (by-value for non-structural
108111
types, by-reference for structural ones) are written `+` for by-value
109112
and `&&` for by(-immutable)-reference. It is sometimes necessary to

trunk/src/libcore/char.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export is_alphabetic,
4141
is_XID_start, is_XID_continue,
4242
is_lowercase, is_uppercase,
4343
is_whitespace, is_alphanumeric,
44-
to_digit, to_lowercase, to_uppercase, maybe_digit, cmp;
44+
to_digit, maybe_digit, cmp;
4545

4646
import is_alphabetic = unicode::derived_property::Alphabetic;
4747
import is_XID_start = unicode::derived_property::XID_Start;
@@ -136,34 +136,6 @@ pure fn maybe_digit(c: char) -> option::t<u8> {
136136
}
137137
}
138138

139-
/*
140-
Function: to_lowercase
141-
142-
Convert a char to the corresponding lower case.
143-
144-
FIXME: works only on ASCII
145-
*/
146-
pure fn to_lowercase(c: char) -> char {
147-
alt c {
148-
'A' to 'Z' { ((c as u8) + 32u8) as char }
149-
_ { c }
150-
}
151-
}
152-
153-
/*
154-
Function: to_uppercase
155-
156-
Convert a char to the corresponding upper case.
157-
158-
FIXME: works only on ASCII
159-
*/
160-
pure fn to_uppercase(c: char) -> char {
161-
alt c {
162-
'a' to 'z' { ((c as u8) - 32u8) as char }
163-
_ { c }
164-
}
165-
}
166-
167139
/*
168140
Function: cmp
169141

trunk/src/libcore/str.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ String manipulation.
77
export eq, lteq, hash, is_empty, is_not_empty, is_whitespace, byte_len,
88
byte_len_range, index,
99
rindex, find, starts_with, ends_with, substr, slice, split, splitn,
10-
split_str, concat, connect, to_lower, to_upper, replace, char_slice,
11-
trim_left, trim_right, trim, unshift_char, shift_char, pop_char,
12-
push_char, is_utf8, from_chars, to_chars, char_len, char_len_range,
13-
char_at, bytes, is_ascii, shift_byte, pop_byte,
10+
split_str, concat, connect, to_upper, replace, char_slice, trim_left,
11+
trim_right, trim, unshift_char, shift_char, pop_char, push_char,
12+
is_utf8, from_chars, to_chars, char_len, char_len_range, char_at,
13+
bytes, is_ascii, shift_byte, pop_byte,
1414
unsafe_from_byte, unsafe_from_bytes, from_char, char_range_at,
1515
str_from_cstr, sbuf, as_buf, push_byte, utf8_char_width, safe_slice,
1616
contains, iter_chars, loop_chars, loop_chars_sub,
@@ -832,27 +832,23 @@ fn connect(v: [str], sep: str) -> str {
832832
ret s;
833833
}
834834

835-
/*
836-
Function: to_lower
837-
838-
Convert a string to lowercase
839-
*/
840-
fn to_lower(s: str) -> str {
841-
let outstr = "";
842-
iter_chars(s) { |c|
843-
push_char(outstr, char::to_lowercase(c));
844-
}
845-
ret outstr;
846-
}
835+
// FIXME: This only handles ASCII
847836
/*
848837
Function: to_upper
849838
850839
Convert a string to uppercase
851840
*/
852841
fn to_upper(s: str) -> str {
853842
let outstr = "";
854-
iter_chars(s) { |c|
855-
push_char(outstr, char::to_uppercase(c));
843+
let ascii_a = 'a' as u8;
844+
let ascii_z = 'z' as u8;
845+
let diff = 32u8;
846+
for byte: u8 in s {
847+
let next;
848+
if ascii_a <= byte && byte <= ascii_z {
849+
next = byte - diff;
850+
} else { next = byte; }
851+
push_byte(outstr, next);
856852
}
857853
ret outstr;
858854
}

trunk/src/test/stdtest/char.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,3 @@ fn test_to_digit_fail_1() {
6060
fn test_to_digit_fail_2() {
6161
char::to_digit('$');
6262
}
63-
64-
#[test]
65-
fn test_to_lowercase() {
66-
assert (char::to_lowercase('H') == 'h');
67-
assert (char::to_lowercase('e') == 'e');
68-
//assert (char::to_lowercase('Ö') == 'ö');
69-
assert (char::to_lowercase('ß') == 'ß');
70-
}
71-
72-
#[test]
73-
fn test_to_uppercase() {
74-
assert (char::to_uppercase('l') == 'L');
75-
assert (char::to_uppercase('Q') == 'Q');
76-
//assert (char::to_uppercase('ü') == 'Ü');
77-
assert (char::to_uppercase('ß') == 'ß');
78-
}

0 commit comments

Comments
 (0)