File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 45921648699a42fa1d257f6a54d2dbe9e46b0e20
2
+ refs/heads/master: c5e0736c2434fbed6b7f249b42b336f0e27804a6
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: 9fc8394d3bce22ab483f98842434c84c396212ae
5
5
refs/heads/try: dff46952ab5c4567d1b5b35bfbd8befc45cdd38e
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