From 74bcfe406b2a43b5a3c44a234ec4a9ff52f77619 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Thu, 7 Jul 2022 11:10:34 +0200 Subject: [PATCH] fix some more clippy lints --- src/flatten_ok.rs | 3 +-- src/lazy_buffer.rs | 20 ++++++++------------ src/permutations.rs | 7 ++----- src/tuple_impl.rs | 2 +- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/flatten_ok.rs b/src/flatten_ok.rs index 21ae1f722..f431c1325 100644 --- a/src/flatten_ok.rs +++ b/src/flatten_ok.rs @@ -76,8 +76,7 @@ where let inner_hint = |inner: &Option| { inner .as_ref() - .map(Iterator::size_hint) - .unwrap_or((0, Some(0))) + .map_or((0, Some(0)), Iterator::size_hint) }; let inner_front = inner_hint(&self.inner_front); let inner_back = inner_hint(&self.inner_back); diff --git a/src/lazy_buffer.rs b/src/lazy_buffer.rs index fa514ec2d..ca24062aa 100644 --- a/src/lazy_buffer.rs +++ b/src/lazy_buffer.rs @@ -28,16 +28,12 @@ where if self.done { return false; } - let next_item = self.it.next(); - match next_item { - Some(x) => { - self.buffer.push(x); - true - } - None => { - self.done = true; - false - } + if let Some(x) = self.it.next() { + self.buffer.push(x); + true + } else { + self.done = true; + false } } @@ -61,7 +57,7 @@ where { type Output = as Index>::Output; - fn index(&self, _index: J) -> &Self::Output { - self.buffer.index(_index) + fn index(&self, index: J) -> &Self::Output { + self.buffer.index(index) } } diff --git a/src/permutations.rs b/src/permutations.rs index f818a2032..36f5836fe 100644 --- a/src/permutations.rs +++ b/src/permutations.rs @@ -113,19 +113,15 @@ where Some(indices.map(|i| vals[i].clone()).collect()) } - PermutationState::Complete(CompleteState::Start { .. }) => None, PermutationState::Complete(CompleteState::Ongoing { ref indices, ref cycles }) => { let k = cycles.len(); - Some(indices[0..k].iter().map(|&i| vals[i].clone()).collect()) }, - PermutationState::Empty => None + PermutationState::Complete(CompleteState::Start { .. }) | PermutationState::Empty => None } } fn count(self) -> usize { - let Permutations { vals, state } = self; - fn from_complete(complete_state: CompleteState) -> usize { match complete_state.remaining() { CompleteStateRemaining::Known(count) => count, @@ -135,6 +131,7 @@ where } } + let Permutations { vals, state } = self; match state { PermutationState::StartUnknownLen { k } => { let n = vals.len() + vals.it.count(); diff --git a/src/tuple_impl.rs b/src/tuple_impl.rs index 1dfa2fb6c..62bfdaffa 100644 --- a/src/tuple_impl.rs +++ b/src/tuple_impl.rs @@ -162,8 +162,8 @@ pub fn tuple_windows(mut iter: I) -> TupleWindows } TupleWindows { - last, iter, + last, } }