diff options
| author | pravic <[email protected]> | 2016-06-06 23:07:53 +0300 |
|---|---|---|
| committer | pravic <[email protected]> | 2016-06-06 23:07:53 +0300 |
| commit | f2db0929feeb53567655dbdebba7e6b1c3f2f69e (patch) | |
| tree | c2cf041f838782f9ddd8994146f52e8f498bfe07 /libcore/iter/mod.rs | |
| parent | add 'netio' native import library (diff) | |
| parent | Merge branch 'nofp_patch' into libcore_nofp (diff) | |
| download | kmd-env-rs-f2db0929feeb53567655dbdebba7e6b1c3f2f69e.tar.xz kmd-env-rs-f2db0929feeb53567655dbdebba7e6b1c3f2f69e.zip | |
Diffstat (limited to 'libcore/iter/mod.rs')
| -rw-r--r-- | libcore/iter/mod.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libcore/iter/mod.rs b/libcore/iter/mod.rs index abc199c..ae1e311 100644 --- a/libcore/iter/mod.rs +++ b/libcore/iter/mod.rs @@ -510,6 +510,7 @@ impl<A, B> Iterator for Chain<A, B> where } #[inline] + #[rustc_inherit_overflow_checks] fn count(self) -> usize { match self.state { ChainState::Both => self.a.count() + self.b.count(), @@ -542,6 +543,23 @@ impl<A, B> Iterator for Chain<A, B> where } #[inline] + fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where + P: FnMut(&Self::Item) -> bool, + { + match self.state { + ChainState::Both => match self.a.find(&mut predicate) { + None => { + self.state = ChainState::Back; + self.b.find(predicate) + } + v => v + }, + ChainState::Front => self.a.find(predicate), + ChainState::Back => self.b.find(predicate), + } + } + + #[inline] fn last(self) -> Option<A::Item> { match self.state { ChainState::Both => { @@ -915,6 +933,7 @@ impl<I> Iterator for Enumerate<I> where I: Iterator { /// /// Might panic if the index of the element overflows a `usize`. #[inline] + #[rustc_inherit_overflow_checks] fn next(&mut self) -> Option<(usize, <I as Iterator>::Item)> { self.iter.next().map(|a| { let ret = (self.count, a); @@ -930,6 +949,7 @@ impl<I> Iterator for Enumerate<I> where I: Iterator { } #[inline] + #[rustc_inherit_overflow_checks] fn nth(&mut self, n: usize) -> Option<(usize, I::Item)> { self.iter.nth(n).map(|a| { let i = self.count + n; @@ -991,6 +1011,7 @@ impl<I: Iterator> Iterator for Peekable<I> { } #[inline] + #[rustc_inherit_overflow_checks] fn count(self) -> usize { (if self.peeked.is_some() { 1 } else { 0 }) + self.iter.count() } @@ -1108,6 +1129,7 @@ impl<I: Iterator> Peekable<I> { /// ``` #[unstable(feature = "peekable_is_empty", issue = "32111")] #[inline] + #[rustc_deprecated(since = "1.10.0", reason = "replaced by .peek().is_none()")] pub fn is_empty(&mut self) -> bool { self.peek().is_none() } |