(core::str) replace byte_index[_from] with index[_from]
This commit is contained in:
parent
280633a728
commit
6ea3d7935e
4 changed files with 23 additions and 21 deletions
|
@ -70,8 +70,8 @@ fn to_str(j: json) -> str {
|
|||
}
|
||||
|
||||
fn rest(s: str) -> str {
|
||||
assert(str::len_chars(s) >= 1u);
|
||||
str::slice_chars(s, 1u, str::len_chars(s))
|
||||
assert(str::len_bytes(s) >= 1u);
|
||||
str::slice(s, 1u, str::len_bytes(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_chars(s, pos, str::len_chars(s)));
|
||||
str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
res = res + str::from_char(c);
|
||||
}
|
||||
|
@ -200,13 +200,13 @@ fn from_str_float(s: str) -> (option<json>, str) {
|
|||
}
|
||||
'.' { break; }
|
||||
_ { ret (some(num(neg * res)),
|
||||
str::slice_chars(s, opos, str::len_chars(s))); }
|
||||
str::slice(s, opos, str::len_bytes(s))); }
|
||||
}
|
||||
}
|
||||
|
||||
if pos == len {
|
||||
ret (some(num(neg * res)),
|
||||
str::slice_chars(s, pos, str::len_chars(s)));
|
||||
str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
|
||||
let dec = 1f;
|
||||
|
@ -221,17 +221,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_chars(s, opos, str::len_chars(s))); }
|
||||
str::slice(s, opos, str::len_bytes(s))); }
|
||||
}
|
||||
}
|
||||
ret (some(num(neg * res)), str::slice_chars(s, pos, str::len_chars(s)));
|
||||
ret (some(num(neg * res)), str::slice(s, pos, str::len_bytes(s)));
|
||||
}
|
||||
|
||||
fn from_str_bool(s: str) -> (option<json>, str) {
|
||||
if (str::starts_with(s, "true")) {
|
||||
(some(boolean(true)), str::slice_chars(s, 4u, str::len_chars(s)))
|
||||
(some(boolean(true)), str::slice(s, 4u, str::len_bytes(s)))
|
||||
} else if (str::starts_with(s, "false")) {
|
||||
(some(boolean(false)), str::slice_chars(s, 5u, str::len_chars(s)))
|
||||
(some(boolean(false)), str::slice(s, 5u, str::len_bytes(s)))
|
||||
} else {
|
||||
(none, s)
|
||||
}
|
||||
|
@ -239,7 +239,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_chars(s, 4u, str::len_chars(s)))
|
||||
(some(null), str::slice(s, 4u, str::len_bytes(s)))
|
||||
} else {
|
||||
(none, s)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue