mirror of
https://github.com/openharmony/third_party_rust_rust-smallvec.git
synced 2026-07-21 01:55:25 -04:00
Implement ExactSizeIterator on Drain and IntoIter
This commit is contained in:
@@ -71,6 +71,11 @@ impl<'a, T: 'a> Iterator for Drain<'a,T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
self.iter.size_hint()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
|
||||
@@ -87,6 +92,8 @@ impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> ExactSizeIterator for Drain<'a, T> { }
|
||||
|
||||
impl<'a, T: 'a> Drop for Drain<'a,T> {
|
||||
fn drop(&mut self) {
|
||||
// Destroy the remaining elements.
|
||||
@@ -524,6 +531,12 @@ impl<A: Array> Iterator for IntoIter<A> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
let size = self.end - self.current;
|
||||
(size, Some(size))
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> DoubleEndedIterator for IntoIter<A> {
|
||||
@@ -541,6 +554,8 @@ impl<A: Array> DoubleEndedIterator for IntoIter<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> ExactSizeIterator for IntoIter<A> { }
|
||||
|
||||
impl<A: Array> IntoIterator for SmallVec<A> {
|
||||
type IntoIter = IntoIter<A>;
|
||||
type Item = A::Item;
|
||||
|
||||
Reference in New Issue
Block a user