File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -1790,10 +1790,8 @@ impl<'self> StrSlice<'self> for &'self str {
1790
1790
if search.matches(b as char) { return Some(i) }
1791
1791
}
1792
1792
} else {
1793
- let mut index = 0;
1794
- for c in self.iter() {
1793
+ for (index, c) in self.char_offset_iter() {
1795
1794
if search.matches(c) { return Some(index); }
1796
- index += c.len_utf8_bytes();
1797
1795
}
1798
1796
}
1799
1797
@@ -1807,15 +1805,14 @@ impl<'self> StrSlice<'self> for &'self str {
1807
1805
/// `Some` containing the byte index of the last matching character
1808
1806
/// or `None` if there is no match
1809
1807
fn rfind<C: CharEq>(&self, search: C) -> Option<uint> {
1810
- let mut index = self.len();
1811
1808
if search.only_ascii() {
1809
+ let mut index = self.len();
1812
1810
for b in self.byte_rev_iter() {
1813
1811
index -= 1;
1814
1812
if search.matches(b as char) { return Some(index); }
1815
1813
}
1816
1814
} else {
1817
- for c in self.rev_iter() {
1818
- index -= c.len_utf8_bytes();
1815
+ for (index, c) in self.char_offset_rev_iter() {
1819
1816
if search.matches(c) { return Some(index); }
1820
1817
}
1821
1818
}
You can’t perform that action at this time.
0 commit comments