str: rm map_chars, replaced by iterators

mapping a function against the elements should not require allocating a
new container, but `collect` still provides the functionality as-needed
This commit is contained in:
Daniel Micay 2013-09-05 01:59:42 -04:00
parent d285ea7910
commit fcc7aff62b

View File

@ -1370,8 +1370,6 @@ pub trait StrSlice<'self> {
fn slice_shift_char(&self) -> (char, &'self str);
fn map_chars(&self, ff: &fn(char) -> char) -> ~str;
fn lev_distance(&self, t: &str) -> uint;
fn subslice_offset(&self, inner: &str) -> uint;
@ -2088,15 +2086,6 @@ impl<'self> StrSlice<'self> for &'self str {
return (ch, next_s);
}
/// Apply a function to each character.
fn map_chars(&self, ff: &fn(char) -> char) -> ~str {
let mut result = with_capacity(self.len());
for cc in self.iter() {
result.push_char(ff(cc));
}
result
}
/// Levenshtein Distance between two strings.
fn lev_distance(&self, t: &str) -> uint {
let slen = self.len();