]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8857 : blake2-ppc/rust/std-str-remove, r=thestinger
authorbors <bors@rust-lang.org>
Fri, 30 Aug 2013 11:40:47 +0000 (04:40 -0700)
committerbors <bors@rust-lang.org>
Fri, 30 Aug 2013 11:40:47 +0000 (04:40 -0700)
These are very easy to replace with methods on string slices, basically
`.char_len()` and `.len()`.

These are the replacement implementations I did to clean these
functions up, but seeing this I propose removal:

/// ...
pub fn count_chars(s: &str, begin: uint, end: uint) -> uint {
    // .slice() checks the char boundaries
    s.slice(begin, end).char_len()
}

/// Counts the number of bytes taken by the first `n` chars in `s`
/// starting from byte index `begin`.
///
/// Fails if there are less than `n` chars past `begin`
pub fn count_bytes<'b>(s: &'b str, begin: uint, n: uint) -> uint {
    s.slice_from(begin).slice_chars(0, n).len()
}

1  2 
src/libstd/str.rs

Simple merge