std: remove substr & str::count_*, methodise char_len, implement slice_chars.

The confusing mixture of byte index and character count meant that every
use of .substr was incorrect; replaced by slice_chars which only uses
character indices. The old behaviour of `.substr(start, n)` can be emulated
via `.slice_from(start).slice_chars(0, n)`.
This commit is contained in:
Huon Wilson 2013-06-11 21:37:22 +10:00
parent 9fff8c6eba
commit 3ac00a9489
10 changed files with 76 additions and 104 deletions

View file

@ -21,7 +21,7 @@ pub fn main() {
let schs: ~[char] = s.iter().collect();
assert!(s.len() == 10u);
assert!(str::char_len(s) == 4u);
assert!(s.char_len() == 4u);
assert!(schs.len() == 4u);
assert!(str::from_chars(schs) == s);
assert!(s.char_at(0u) == 'e');