1
Fork 0

(core::str) mostly rename len -> len_chars

This commit is contained in:
Kevin Cantu 2012-02-21 21:04:29 -08:00 committed by Marijn Haverbeke
parent 7a6498668f
commit 98447f5236
17 changed files with 54 additions and 52 deletions

View file

@ -70,8 +70,8 @@ fn to_str(j: json) -> str {
}
fn rest(s: str) -> str {
assert(str::len(s) >= 1u);
str::slice(s, 1u, str::len(s))
assert(str::len_chars(s) >= 1u);
str::slice(s, 1u, str::len_chars(s))
}
fn from_str_str(s: str) -> (option<json>, str) {
@ -99,7 +99,7 @@ fn from_str_str(s: str) -> (option<json>, str) {
cont;
} else if (c == '"') {
ret (some(string(res)),
str::slice(s, pos, str::len(s)));
str::slice(s, pos, str::len_chars(s)));
}
res = res + str::from_char(c);
}
@ -200,12 +200,12 @@ fn from_str_float(s: str) -> (option<json>, str) {
}
'.' { break; }
_ { ret (some(num(neg * res)),
str::slice(s, opos, str::len(s))); }
str::slice(s, opos, str::len_chars(s))); }
}
}
if pos == len {
ret (some(num(neg * res)), str::slice(s, pos, str::len(s)));
ret (some(num(neg * res)), str::slice(s, pos, str::len_chars(s)));
}
let dec = 1f;
@ -220,17 +220,17 @@ fn from_str_float(s: str) -> (option<json>, str) {
res += (((c as int) - ('0' as int)) as float) * dec;
}
_ { ret (some(num(neg * res)),
str::slice(s, opos, str::len(s))); }
str::slice(s, opos, str::len_chars(s))); }
}
}
ret (some(num(neg * res)), str::slice(s, pos, str::len(s)));
ret (some(num(neg * res)), str::slice(s, pos, str::len_chars(s)));
}
fn from_str_bool(s: str) -> (option<json>, str) {
if (str::starts_with(s, "true")) {
(some(boolean(true)), str::slice(s, 4u, str::len(s)))
(some(boolean(true)), str::slice(s, 4u, str::len_chars(s)))
} else if (str::starts_with(s, "false")) {
(some(boolean(false)), str::slice(s, 5u, str::len(s)))
(some(boolean(false)), str::slice(s, 5u, str::len_chars(s)))
} else {
(none, s)
}
@ -238,7 +238,7 @@ fn from_str_bool(s: str) -> (option<json>, str) {
fn from_str_null(s: str) -> (option<json>, str) {
if (str::starts_with(s, "null")) {
(some(null), str::slice(s, 4u, str::len(s)))
(some(null), str::slice(s, 4u, str::len_chars(s)))
} else {
(none, s)
}