File tree 1 file changed +7
-7
lines changed
1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -209,20 +209,20 @@ impl<'a> DoubleEndedIterator<char> for Chars<'a> {
209
209
/// Use with the `std::iter` module.
210
210
#[ deriving( Clone ) ]
211
211
pub struct CharOffsets < ' a > {
212
- front : uint ,
213
- back : uint ,
212
+ front_offset : uint ,
214
213
iter : Chars < ' a > ,
215
214
}
216
215
217
216
impl < ' a > Iterator < ( uint , char ) > for CharOffsets < ' a > {
218
217
#[ inline]
219
218
fn next ( & mut self ) -> Option < ( uint , char ) > {
219
+ let ( pre_len, _) = self . iter . iter . size_hint ( ) ;
220
220
match self . iter . next ( ) {
221
221
None => None ,
222
222
Some ( ch) => {
223
- let index = self . front ;
223
+ let index = self . front_offset ;
224
224
let ( len, _) = self . iter . iter . size_hint ( ) ;
225
- self . front += self . back - self . front - len;
225
+ self . front_offset += pre_len - len;
226
226
Some ( ( index, ch) )
227
227
}
228
228
}
@@ -241,8 +241,8 @@ impl<'a> DoubleEndedIterator<(uint, char)> for CharOffsets<'a> {
241
241
None => None ,
242
242
Some ( ch) => {
243
243
let ( len, _) = self . iter . iter . size_hint ( ) ;
244
- self . back - = self . back - self . front - len;
245
- Some ( ( self . back , ch) )
244
+ let index = self . front_offset + len;
245
+ Some ( ( index , ch) )
246
246
}
247
247
}
248
248
}
@@ -1680,7 +1680,7 @@ impl<'a> StrSlice<'a> for &'a str {
1680
1680
1681
1681
#[ inline]
1682
1682
fn char_indices ( & self ) -> CharOffsets < ' a > {
1683
- CharOffsets { front : 0 , back : self . len ( ) , iter : self . chars ( ) }
1683
+ CharOffsets { front_offset : 0 , iter : self . chars ( ) }
1684
1684
}
1685
1685
1686
1686
#[ inline]
You can’t perform that action at this time.
0 commit comments