Skip to content

Commit 6b7063a

Browse files
bors[bot]hellow554
andauthored
Merge #630
630: Hellow554 lints 3 r=phimuemue a=phimuemue Next batch of #618. bors r+ Co-authored-by: Marcel Hellwig <[email protected]>
2 parents deae58e + 412b75b commit 6b7063a

16 files changed

+53
-57
lines changed

clippy.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.36.0"

src/adaptors/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<I> PutBack<I>
208208
/// If a value is already in the put back slot, it is overwritten.
209209
#[inline]
210210
pub fn put_back(&mut self, x: I::Item) {
211-
self.top = Some(x)
211+
self.top = Some(x);
212212
}
213213
}
214214

src/adaptors/multi_product.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn multi_cartesian_product<H>(iters: H) -> MultiProduct<<H::Item as IntoIter
4040
}
4141

4242
#[derive(Clone, Debug)]
43-
/// Holds the state of a single iterator within a MultiProduct.
43+
/// Holds the state of a single iterator within a `MultiProduct`.
4444
struct MultiProductIter<I>
4545
where I: Iterator + Clone,
4646
I::Item: Clone
@@ -50,7 +50,7 @@ struct MultiProductIter<I>
5050
iter_orig: I,
5151
}
5252

53-
/// Holds the current state during an iteration of a MultiProduct.
53+
/// Holds the current state during an iteration of a `MultiProduct`.
5454
#[derive(Debug)]
5555
enum MultiProductIterState {
5656
StartOfIter,

src/combinations_with_replacement.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ where
9292
// We need to update the rightmost non-max value
9393
// and all those to the right
9494
for indices_index in increment_from..self.indices.len() {
95-
self.indices[indices_index] = increment_value
95+
self.indices[indices_index] = increment_value;
9696
}
9797
Some(self.current())
9898
}

src/exactly_one_err.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use crate::size_hint;
1111
/// Iterator returned for the error case of `IterTools::exactly_one()`
1212
/// This iterator yields exactly the same elements as the input iterator.
1313
///
14-
/// During the execution of exactly_one the iterator must be mutated. This wrapper
14+
/// During the execution of `exactly_one` the iterator must be mutated. This wrapper
1515
/// effectively "restores" the state of the input iterator when it's handed back.
1616
///
17-
/// This is very similar to PutBackN except this iterator only supports 0-2 elements and does not
17+
/// This is very similar to `PutBackN` except this iterator only supports 0-2 elements and does not
1818
/// use a `Vec`.
1919
#[derive(Clone)]
2020
pub struct ExactlyOneError<I>

src/flatten_ok.rs

+16-16
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ where
4444
if let Some(inner) = &mut self.inner_front {
4545
if let Some(item) = inner.next() {
4646
return Some(Ok(item));
47-
} else {
48-
// This is necessary for the iterator to implement `FusedIterator`
49-
// with only the original iterator being fused.
50-
self.inner_front = None;
5147
}
48+
49+
// This is necessary for the iterator to implement `FusedIterator`
50+
// with only the original iterator being fused.
51+
self.inner_front = None;
5252
}
5353

5454
match self.iter.next() {
@@ -59,11 +59,11 @@ where
5959
if let Some(inner) = &mut self.inner_back {
6060
if let Some(item) = inner.next() {
6161
return Some(Ok(item));
62-
} else {
63-
// This is necessary for the iterator to implement `FusedIterator`
64-
// with only the original iterator being fused.
65-
self.inner_back = None;
6662
}
63+
64+
// This is necessary for the iterator to implement `FusedIterator`
65+
// with only the original iterator being fused.
66+
self.inner_back = None;
6767
} else {
6868
return None;
6969
}
@@ -103,11 +103,11 @@ where
103103
if let Some(inner) = &mut self.inner_back {
104104
if let Some(item) = inner.next_back() {
105105
return Some(Ok(item));
106-
} else {
107-
// This is necessary for the iterator to implement `FusedIterator`
108-
// with only the original iterator being fused.
109-
self.inner_back = None;
110106
}
107+
108+
// This is necessary for the iterator to implement `FusedIterator`
109+
// with only the original iterator being fused.
110+
self.inner_back = None;
111111
}
112112

113113
match self.iter.next_back() {
@@ -118,11 +118,11 @@ where
118118
if let Some(inner) = &mut self.inner_front {
119119
if let Some(item) = inner.next_back() {
120120
return Some(Ok(item));
121-
} else {
122-
// This is necessary for the iterator to implement `FusedIterator`
123-
// with only the original iterator being fused.
124-
self.inner_front = None;
125121
}
122+
123+
// This is necessary for the iterator to implement `FusedIterator`
124+
// with only the original iterator being fused.
125+
self.inner_front = None;
126126
} else {
127127
return None;
128128
}

src/groupbylazy.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::{Cell, RefCell};
22
use alloc::vec::{self, Vec};
33

4-
/// A trait to unify FnMut for GroupBy with the chunk key in IntoChunks
4+
/// A trait to unify `FnMut` for `GroupBy` with the chunk key in `IntoChunks`
55
trait KeyFunction<A> {
66
type Key;
77
fn call_mut(&mut self, arg: A) -> Self::Key;
@@ -18,7 +18,7 @@ impl<A, K, F: ?Sized> KeyFunction<A> for F
1818
}
1919

2020

21-
/// ChunkIndex acts like the grouping key function for IntoChunks
21+
/// `ChunkIndex` acts like the grouping key function for `IntoChunks`
2222
#[derive(Debug)]
2323
struct ChunkIndex {
2424
size: usize,
@@ -330,7 +330,7 @@ impl<K, I, F> GroupBy<K, I, F>
330330

331331
/// `client`: Index of group
332332
fn drop_group(&self, client: usize) {
333-
self.inner.borrow_mut().drop_group(client)
333+
self.inner.borrow_mut().drop_group(client);
334334
}
335335
}
336336

@@ -482,7 +482,7 @@ impl<I> IntoChunks<I>
482482

483483
/// `client`: Index of chunk
484484
fn drop_group(&self, client: usize) {
485-
self.inner.borrow_mut().drop_group(client)
485+
self.inner.borrow_mut().drop_group(client);
486486
}
487487
}
488488

src/intersperse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub struct IntersperseWith<I, ElemF>
5555
peek: Option<I::Item>,
5656
}
5757

58-
/// Create a new IntersperseWith iterator
58+
/// Create a new `IntersperseWith` iterator
5959
pub fn intersperse_with<I, ElemF>(iter: I, elt: ElemF) -> IntersperseWith<I, ElemF>
6060
where I: Iterator,
6161
{

src/lazy_buffer.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ where
2828
if self.done {
2929
return false;
3030
}
31-
let next_item = self.it.next();
32-
match next_item {
33-
Some(x) => {
34-
self.buffer.push(x);
35-
true
36-
}
37-
None => {
38-
self.done = true;
39-
false
40-
}
31+
if let Some(x) = self.it.next() {
32+
self.buffer.push(x);
33+
true
34+
} else {
35+
self.done = true;
36+
false
4137
}
4238
}
4339

@@ -61,7 +57,7 @@ where
6157
{
6258
type Output = <Vec<I::Item> as Index<J>>::Output;
6359

64-
fn index(&self, _index: J) -> &Self::Output {
65-
self.buffer.index(_index)
60+
fn index(&self, index: J) -> &Self::Output {
61+
self.buffer.index(index)
6662
}
6763
}

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ pub trait Itertools : Iterator {
11111111
/// ```
11121112
#[cfg(feature = "use_alloc")]
11131113
fn multi_cartesian_product(self) -> MultiProduct<<Self::Item as IntoIterator>::IntoIter>
1114-
where Self: Iterator + Sized,
1114+
where Self: Sized,
11151115
Self::Item: IntoIterator,
11161116
<Self::Item as IntoIterator>::IntoIter: Clone,
11171117
<Self::Item as IntoIterator>::Item: Clone
@@ -1953,7 +1953,7 @@ pub trait Itertools : Iterator {
19531953
where F: FnMut(Self::Item),
19541954
Self: Sized,
19551955
{
1956-
self.for_each(f)
1956+
self.for_each(f);
19571957
}
19581958

19591959
/// Combine all an iterator's elements into one element by using [`Extend`].

src/pad_tail.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
debug_fmt_fields!(PadUsing, iter, min, pos);
2424
}
2525

26-
/// Create a new **PadUsing** iterator.
26+
/// Create a new `PadUsing` iterator.
2727
pub fn pad_using<I, F>(iter: I, min: usize, filler: F) -> PadUsing<I, F>
2828
where I: Iterator,
2929
F: FnMut(usize) -> I::Item

src/peeking_take_while.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ where
9090
debug_fmt_fields!(PeekingTakeWhile, iter);
9191
}
9292

93-
/// Create a PeekingTakeWhile
93+
/// Create a `PeekingTakeWhile`
9494
pub fn peeking_take_while<I, F>(iter: &mut I, f: F) -> PeekingTakeWhile<I, F>
9595
where I: Iterator,
9696
{

src/permutations.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,15 @@ where
113113

114114
Some(indices.map(|i| vals[i].clone()).collect())
115115
}
116-
PermutationState::Complete(CompleteState::Start { .. }) => None,
117116
PermutationState::Complete(CompleteState::Ongoing { ref indices, ref cycles }) => {
118117
let k = cycles.len();
119-
120118
Some(indices[0..k].iter().map(|&i| vals[i].clone()).collect())
121119
},
122-
PermutationState::Empty => None
120+
PermutationState::Complete(CompleteState::Start { .. }) | PermutationState::Empty => None
123121
}
124122
}
125123

126124
fn count(self) -> usize {
127-
let Permutations { vals, state } = self;
128-
129125
fn from_complete(complete_state: CompleteState) -> usize {
130126
match complete_state.remaining() {
131127
CompleteStateRemaining::Known(count) => count,
@@ -135,6 +131,7 @@ where
135131
}
136132
}
137133

134+
let Permutations { vals, state } = self;
138135
match state {
139136
PermutationState::StartUnknownLen { k } => {
140137
let n = vals.len() + vals.it.count();

src/size_hint.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//! Arithmetic on **Iterator** *.size_hint()* values.
1+
//! Arithmetic on `Iterator.size_hint()` values.
22
//!
33
44
use std::usize;
55
use std::cmp;
66
use std::u32;
77

8-
/// **SizeHint** is the return type of **Iterator::size_hint()**.
8+
/// `SizeHint` is the return type of `Iterator::size_hint()`.
99
pub type SizeHint = (usize, Option<usize>);
1010

11-
/// Add **SizeHint** correctly.
11+
/// Add `SizeHint` correctly.
1212
#[inline]
1313
pub fn add(a: SizeHint, b: SizeHint) -> SizeHint {
1414
let min = a.0.saturating_add(b.0);
@@ -20,7 +20,7 @@ pub fn add(a: SizeHint, b: SizeHint) -> SizeHint {
2020
(min, max)
2121
}
2222

23-
/// Add **x** correctly to a **SizeHint**.
23+
/// Add `x` correctly to a `SizeHint`.
2424
#[inline]
2525
pub fn add_scalar(sh: SizeHint, x: usize) -> SizeHint {
2626
let (mut low, mut hi) = sh;
@@ -29,7 +29,7 @@ pub fn add_scalar(sh: SizeHint, x: usize) -> SizeHint {
2929
(low, hi)
3030
}
3131

32-
/// Sbb **x** correctly to a **SizeHint**.
32+
/// Subtract `x` correctly from a `SizeHint`.
3333
#[inline]
3434
#[allow(dead_code)]
3535
pub fn sub_scalar(sh: SizeHint, x: usize) -> SizeHint {
@@ -40,7 +40,7 @@ pub fn sub_scalar(sh: SizeHint, x: usize) -> SizeHint {
4040
}
4141

4242

43-
/// Multiply **SizeHint** correctly
43+
/// Multiply `SizeHint` correctly
4444
///
4545
/// ```ignore
4646
/// use std::usize;
@@ -66,7 +66,7 @@ pub fn mul(a: SizeHint, b: SizeHint) -> SizeHint {
6666
(low, hi)
6767
}
6868

69-
/// Multiply **x** correctly with a **SizeHint**.
69+
/// Multiply `x` correctly with a `SizeHint`.
7070
#[inline]
7171
pub fn mul_scalar(sh: SizeHint, x: usize) -> SizeHint {
7272
let (mut low, mut hi) = sh;
@@ -75,7 +75,7 @@ pub fn mul_scalar(sh: SizeHint, x: usize) -> SizeHint {
7575
(low, hi)
7676
}
7777

78-
/// Raise `base` correctly by a **`SizeHint`** exponent.
78+
/// Raise `base` correctly by a `SizeHint` exponent.
7979
#[inline]
8080
pub fn pow_scalar_base(base: usize, exp: SizeHint) -> SizeHint {
8181
let exp_low = cmp::min(exp.0, u32::MAX as usize) as u32;

src/tuple_impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ pub fn tuple_windows<I, T>(mut iter: I) -> TupleWindows<I, T>
162162
}
163163

164164
TupleWindows {
165-
last,
166165
iter,
166+
last,
167167
}
168168
}
169169

tests/quick.rs

+2
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ where
258258
let mut it = get_it();
259259

260260
for _ in 0..(counts.len() - 1) {
261+
#[allow(clippy::manual_assert)]
261262
if it.next().is_none() {
262263
panic!("Iterator shouldn't be finished, may not be deterministic");
263264
}
@@ -1548,6 +1549,7 @@ quickcheck! {
15481549
fn counts(nums: Vec<isize>) -> TestResult {
15491550
let counts = nums.iter().counts();
15501551
for (&item, &count) in counts.iter() {
1552+
#[allow(clippy::absurd_extreme_comparisons)]
15511553
if count <= 0 {
15521554
return TestResult::failed();
15531555
}

0 commit comments

Comments
 (0)