Skip to content

Commit 66a307b

Browse files
fix a bunch of clippy warnings
1 parent 423d520 commit 66a307b

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub trait StreamingIterator {
178178
Self: Sized,
179179
F: FnMut(&Self::Item) -> bool,
180180
{
181-
Filter { it: self, f: f }
181+
Filter { it: self, f }
182182
}
183183

184184
/// Creates an iterator which both filters and maps by applying a closure to elements.
@@ -190,7 +190,7 @@ pub trait StreamingIterator {
190190
{
191191
FilterMap {
192192
it: self,
193-
f: f,
193+
f,
194194
item: None,
195195
}
196196
}
@@ -280,7 +280,7 @@ pub trait StreamingIterator {
280280
{
281281
Map {
282282
it: self,
283-
f: f,
283+
f,
284284
item: None,
285285
}
286286
}
@@ -308,7 +308,7 @@ pub trait StreamingIterator {
308308
Self: Sized,
309309
F: Fn(&Self::Item) -> &B,
310310
{
311-
MapRef { it: self, f: f }
311+
MapRef { it: self, f }
312312
}
313313

314314
/// Consumes the first `n` elements of the iterator, returning the next one.
@@ -362,7 +362,7 @@ pub trait StreamingIterator {
362362
where
363363
Self: Sized,
364364
{
365-
Skip { it: self, n: n }
365+
Skip { it: self, n }
366366
}
367367

368368
/// Creates an iterator that skips initial elements matching a predicate.
@@ -374,7 +374,7 @@ pub trait StreamingIterator {
374374
{
375375
SkipWhile {
376376
it: self,
377-
f: f,
377+
f,
378378
done: false,
379379
}
380380
}
@@ -387,7 +387,7 @@ pub trait StreamingIterator {
387387
{
388388
Take {
389389
it: self,
390-
n: n,
390+
n,
391391
done: false,
392392
}
393393
}
@@ -401,7 +401,7 @@ pub trait StreamingIterator {
401401
{
402402
TakeWhile {
403403
it: self,
404-
f: f,
404+
f,
405405
done: false,
406406
}
407407
}
@@ -1970,7 +1970,7 @@ where
19701970
{
19711971
if self.n > 0 {
19721972
// nth(n) skips n+1
1973-
if let None = self.it.nth(self.n - 1) {
1973+
if self.it.nth(self.n - 1).is_none() {
19741974
return init;
19751975
}
19761976
}
@@ -1994,7 +1994,7 @@ where
19941994
{
19951995
if self.n > 0 {
19961996
// nth(n) skips n+1
1997-
if let None = self.it.nth(self.n - 1) {
1997+
if self.it.nth(self.n - 1).is_none() {
19981998
return init;
19991999
}
20002000
}

src/sources.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,12 @@ where
337337
}
338338

339339
#[inline]
340-
fn fold<Acc, Fold>(self, init: Acc, mut f: Fold) -> Acc
340+
fn fold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc
341341
where
342342
Self: Sized,
343343
Fold: FnMut(Acc, &Self::Item) -> Acc,
344344
{
345-
self.it.fold(init, move |acc, item| f(acc, item))
345+
self.it.fold(init, f)
346346
}
347347
}
348348

@@ -356,12 +356,12 @@ where
356356
}
357357

358358
#[inline]
359-
fn rfold<Acc, Fold>(self, init: Acc, mut f: Fold) -> Acc
359+
fn rfold<Acc, Fold>(self, init: Acc, f: Fold) -> Acc
360360
where
361361
Self: Sized,
362362
Fold: FnMut(Acc, &Self::Item) -> Acc,
363363
{
364-
self.it.rev().fold(init, move |acc, item| f(acc, item))
364+
self.it.rev().fold(init, f)
365365
}
366366
}
367367

@@ -447,12 +447,12 @@ where
447447
}
448448

449449
#[inline]
450-
fn fold_mut<B, F>(self, init: B, mut f: F) -> B
450+
fn fold_mut<B, F>(self, init: B, f: F) -> B
451451
where
452452
Self: Sized,
453453
F: FnMut(B, &mut Self::Item) -> B,
454454
{
455-
self.it.fold(init, move |acc, item| f(acc, item))
455+
self.it.fold(init, f)
456456
}
457457
}
458458

@@ -461,12 +461,12 @@ where
461461
I: DoubleEndedIterator<Item = &'a mut T>,
462462
{
463463
#[inline]
464-
fn rfold_mut<B, F>(self, init: B, mut f: F) -> B
464+
fn rfold_mut<B, F>(self, init: B, f: F) -> B
465465
where
466466
Self: Sized,
467467
F: FnMut(B, &mut Self::Item) -> B,
468468
{
469-
self.it.rev().fold(init, move |acc, item| f(acc, item))
469+
self.it.rev().fold(init, f)
470470
}
471471
}
472472

@@ -594,10 +594,7 @@ impl<T, F: FnOnce() -> T> StreamingIterator for OnceWith<T, F> {
594594

595595
#[inline]
596596
fn advance(&mut self) {
597-
self.item = match self.gen.take() {
598-
Some(gen) => Some(gen()),
599-
None => None,
600-
};
597+
self.item = self.gen.take().map(|gen| gen());
601598
}
602599

603600
#[inline]

0 commit comments

Comments
 (0)