Skip to content

Commit

Permalink
allow clippy::zero_sized_map_values
Browse files Browse the repository at this point in the history
also move comment why using a hashmap in the first place
  • Loading branch information
hellow554 committed Jul 7, 2022
1 parent c5f60ea commit bc52825
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/adaptors/multi_product.rs
Expand Up @@ -114,7 +114,7 @@ impl<I> MultiProduct<I>
/// Returns true if iteration has started and has not yet finished; false
/// otherwise.
fn in_progress(&self) -> bool {
self.0.last().map_or(false, |last| last.in_progress())
self.0.last().map_or(false, MultiProductIter::in_progress)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/groupbylazy.rs
Expand Up @@ -111,7 +111,7 @@ impl<K, I, F> GroupInner<K, I, F>
if client < self.oldest_buffered_group {
return None;
}
let elt = self.buffer.get_mut(bufidx).and_then(|queue| queue.next());
let elt = self.buffer.get_mut(bufidx).and_then(Iterator::next);
if elt.is_none() && client == self.oldest_buffered_group {
// FIXME: VecDeque is unfortunately not zero allocation when empty,
// so we do this job manually.
Expand Down
2 changes: 1 addition & 1 deletion src/kmerge_impl.rs
Expand Up @@ -215,7 +215,7 @@ impl<I, F> Iterator for KMergeBy<I, F>
fn size_hint(&self) -> (usize, Option<usize>) {
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
self.heap.iter()
.map(|i| i.size_hint())
.map(HeadTail::size_hint)
.fold1(size_hint::add)
.unwrap_or((0, Some(0)))
}
Expand Down
2 changes: 1 addition & 1 deletion src/tuple_impl.rs
Expand Up @@ -63,7 +63,7 @@ impl<T> Iterator for TupleBuffer<T>
0
} else {
buffer.iter()
.position(|x| x.is_none())
.position(Option::is_none)
.unwrap_or_else(|| buffer.len())
};
(len, Some(len))
Expand Down
9 changes: 6 additions & 3 deletions src/unique_impl.rs
@@ -1,3 +1,8 @@
// Use a Hashmap for the Entry API in order to prevent hashing twice.
// This can maybe be replaced with a HashSet once `get_or_insert_with`
// or a proper Entry API for Hashset is stable and meets this msrv
#![allow(clippy::zero_sized_map_values)]

use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::hash::Hash;
Expand All @@ -11,9 +16,7 @@ use std::iter::FusedIterator;
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
pub struct UniqueBy<I: Iterator, V, F> {
iter: I,
// Use a Hashmap for the Entry API in order to prevent hashing twice.
// This can maybe be replaced with a HashSet once `get_or_insert_with`
// or a proper Entry API for Hashset is stable and meets this msrv
// see comment for `allow(clippy::zero_sized_map_values)` for reasoning
used: HashMap<V, ()>,
f: F,
}
Expand Down

0 comments on commit bc52825

Please sign in to comment.