Skip to content

Commit 82d4a4c

Browse files
committed
allow clippy::zero_sized_map_values
also move comment why using a hashmap in the first place
1 parent 93a81ed commit 82d4a4c

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/adaptors/multi_product.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<I> MultiProduct<I>
114114
/// Returns true if iteration has started and has not yet finished; false
115115
/// otherwise.
116116
fn in_progress(&self) -> bool {
117-
self.0.last().map_or(false, |last| last.in_progress())
117+
self.0.last().map_or(false, MultiProductIter::in_progress)
118118
}
119119
}
120120

src/groupbylazy.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<K, I, F> GroupInner<K, I, F>
111111
if client < self.oldest_buffered_group {
112112
return None;
113113
}
114-
let elt = self.buffer.get_mut(bufidx).and_then(|queue| queue.next());
114+
let elt = self.buffer.get_mut(bufidx).and_then(Iterator::next);
115115
if elt.is_none() && client == self.oldest_buffered_group {
116116
// FIXME: VecDeque is unfortunately not zero allocation when empty,
117117
// so we do this job manually.

src/kmerge_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ impl<I, F> Iterator for KMergeBy<I, F>
215215
fn size_hint(&self) -> (usize, Option<usize>) {
216216
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
217217
self.heap.iter()
218-
.map(|i| i.size_hint())
218+
.map(HeadTail::size_hint)
219219
.fold1(size_hint::add)
220220
.unwrap_or((0, Some(0)))
221221
}

src/tuple_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<T> Iterator for TupleBuffer<T>
6363
0
6464
} else {
6565
buffer.iter()
66-
.position(|x| x.is_none())
66+
.position(Option::is_none)
6767
.unwrap_or_else(|| buffer.len())
6868
};
6969
(len, Some(len))

src/unique_impl.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Use a Hashmap for the Entry API in order to prevent hashing twice.
2+
// This can maybe be replaced with a HashSet once `get_or_insert_with`
3+
// or a proper Entry API for Hashset is stable and meets this msrv
4+
#![allow(clippy::zero_sized_map_values)]
5+
16
use std::collections::HashMap;
27
use std::collections::hash_map::Entry;
38
use std::hash::Hash;
@@ -11,9 +16,7 @@ use std::iter::FusedIterator;
1116
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
1217
pub struct UniqueBy<I: Iterator, V, F> {
1318
iter: I,
14-
// Use a Hashmap for the Entry API in order to prevent hashing twice.
15-
// This can maybe be replaced with a HashSet once `get_or_insert_with`
16-
// or a proper Entry API for Hashset is stable and meets this msrv
19+
// see comment for `allow(clippy::zero_sized_map_values)` for reasoning
1720
used: HashMap<V, ()>,
1821
f: F,
1922
}

0 commit comments

Comments
 (0)