From bc52825a5af0c8769b036e79796371cd7556b236 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Thu, 7 Jul 2022 11:06:46 +0200 Subject: [PATCH] allow clippy::zero_sized_map_values also move comment why using a hashmap in the first place --- src/adaptors/multi_product.rs | 2 +- src/groupbylazy.rs | 2 +- src/kmerge_impl.rs | 2 +- src/tuple_impl.rs | 2 +- src/unique_impl.rs | 9 ++++++--- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/adaptors/multi_product.rs b/src/adaptors/multi_product.rs index d3be0a6fd..f7bb48f72 100644 --- a/src/adaptors/multi_product.rs +++ b/src/adaptors/multi_product.rs @@ -114,7 +114,7 @@ impl MultiProduct /// 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) } } diff --git a/src/groupbylazy.rs b/src/groupbylazy.rs index 05a8d507b..0124188c1 100644 --- a/src/groupbylazy.rs +++ b/src/groupbylazy.rs @@ -111,7 +111,7 @@ impl GroupInner 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. diff --git a/src/kmerge_impl.rs b/src/kmerge_impl.rs index 509d5fc6a..0dfaba3a0 100644 --- a/src/kmerge_impl.rs +++ b/src/kmerge_impl.rs @@ -215,7 +215,7 @@ impl Iterator for KMergeBy fn size_hint(&self) -> (usize, Option) { #[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))) } diff --git a/src/tuple_impl.rs b/src/tuple_impl.rs index b3704d176..f1442d151 100644 --- a/src/tuple_impl.rs +++ b/src/tuple_impl.rs @@ -63,7 +63,7 @@ impl Iterator for TupleBuffer 0 } else { buffer.iter() - .position(|x| x.is_none()) + .position(Option::is_none) .unwrap_or_else(|| buffer.len()) }; (len, Some(len)) diff --git a/src/unique_impl.rs b/src/unique_impl.rs index 3f9082662..25a25a963 100644 --- a/src/unique_impl.rs +++ b/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; @@ -11,9 +16,7 @@ use std::iter::FusedIterator; #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] pub struct UniqueBy { 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, f: F, }