Skip to content

Added ExactSizeIterator support. #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,12 @@ impl<'a, K, V> DoubleEndedIterator for Keys<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for Keys<'a, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}

pub struct Values<'a, K: 'a, V: 'a> {
iter: SliceIter<'a, Bucket<K, V>>,
}
Expand Down Expand Up @@ -1231,6 +1237,12 @@ impl<'a, K, V> DoubleEndedIterator for Values<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}

pub struct ValuesMut<'a, K: 'a, V: 'a> {
iter: SliceIterMut<'a, Bucket<K, V>>,
}
Expand Down Expand Up @@ -1265,6 +1277,12 @@ impl<'a, K, V> DoubleEndedIterator for ValuesMut<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for ValuesMut<'a, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}

pub struct Iter<'a, K: 'a, V: 'a> {
iter: SliceIter<'a, Bucket<K, V>>,
}
Expand Down Expand Up @@ -1299,6 +1317,12 @@ impl<'a, K, V> DoubleEndedIterator for Iter<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for Iter<'a, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}

pub struct IterMut<'a, K: 'a, V: 'a> {
iter: SliceIterMut<'a, Bucket<K, V>>,
}
Expand Down Expand Up @@ -1333,6 +1357,12 @@ impl<'a, K, V> DoubleEndedIterator for IterMut<'a, K, V> {
}
}

impl<'a, K, V> ExactSizeIterator for IterMut<'a, K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}

pub struct IntoIter<K, V> {
iter: VecIntoIter<Bucket<K, V>>,
}
Expand Down Expand Up @@ -1367,6 +1397,13 @@ impl<'a, K, V> DoubleEndedIterator for IntoIter<K, V> {
}
}

impl<K, V> ExactSizeIterator for IntoIter<K, V> {
fn len(&self) -> usize {
self.iter.len()
}
}


impl<'a, K, V, S> IntoIterator for &'a OrderMap<K, V, S>
where K: Hash + Eq,
S: BuildHasher,
Expand Down