Skip to content

Commit

Permalink
Hide unnecessary iterator visibility
Browse files Browse the repository at this point in the history
(cherry picked from commit 9f2b14d)
  • Loading branch information
cuviper committed Jun 16, 2022
1 parent 20cf99a commit 971f8b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ impl<K, V, S> IndexMap<K, V, S> {
/// [`keys`]: struct.IndexMap.html#method.keys
/// [`IndexMap`]: struct.IndexMap.html
pub struct Keys<'a, K, V> {
pub(crate) iter: SliceIter<'a, Bucket<K, V>>,
iter: SliceIter<'a, Bucket<K, V>>,
}

impl<'a, K, V> Iterator for Keys<'a, K, V> {
Expand Down Expand Up @@ -1137,7 +1137,7 @@ impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IterMut<'_, K, V> {
/// [`into_iter`]: struct.IndexMap.html#method.into_iter
/// [`IndexMap`]: struct.IndexMap.html
pub struct IntoIter<K, V> {
pub(crate) iter: vec::IntoIter<Bucket<K, V>>,
iter: vec::IntoIter<Bucket<K, V>>,
}

impl<K, V> Iterator for IntoIter<K, V> {
Expand Down
15 changes: 8 additions & 7 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl<T, S> IndexSet<T, S> {
/// Return an iterator over the values of the set, in their order
pub fn iter(&self) -> Iter<'_, T> {
Iter {
iter: self.map.keys().iter,
iter: self.map.as_entries().iter(),
}
}

Expand Down Expand Up @@ -602,8 +602,10 @@ where
where
F: FnMut(&T, &T) -> Ordering,
{
let mut entries = self.into_entries();
entries.sort_by(move |a, b| cmp(&a.key, &b.key));
IntoIter {
iter: self.map.sorted_by(move |a, _, b, _| cmp(a, b)).iter,
iter: entries.into_iter(),
}
}

Expand Down Expand Up @@ -633,11 +635,10 @@ where
where
F: FnMut(&T, &T) -> Ordering,
{
let mut entries = self.into_entries();
entries.sort_unstable_by(move |a, b| cmp(&a.key, &b.key));
IntoIter {
iter: self
.map
.sorted_unstable_by(move |a, _, b, _| cmp(a, b))
.iter,
iter: entries.into_iter(),
}
}

Expand Down Expand Up @@ -877,7 +878,7 @@ impl<T, S> IntoIterator for IndexSet<T, S> {

fn into_iter(self) -> Self::IntoIter {
IntoIter {
iter: self.map.into_iter().iter,
iter: self.into_entries().into_iter(),
}
}
}
Expand Down

0 comments on commit 971f8b9

Please sign in to comment.