Skip to content

Commit

Permalink
Hide unnecessary iterator visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Apr 1, 2022
1 parent 7242c54 commit 9f2b14d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,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 @@ -1176,7 +1176,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
13 changes: 7 additions & 6 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,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 @@ -638,11 +640,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 @@ -907,7 +908,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 9f2b14d

Please sign in to comment.