Skip to content

Commit c620ae8

Browse files
bors[bot]phimuemue
andauthored
Merge #411
411: Use field init shorthand r=jswrenn a=phimuemue I suggest that we use field init shorthand ([available since Rust 1.17](https://doc.rust-lang.org/nightly/edition-guide/rust-2018/data-types/field-init-shorthand.html)) whenever possible, as it seems easier and canonical to me. Co-authored-by: philipp <[email protected]>
2 parents f152f5e + 77c2f73 commit c620ae8

18 files changed

+47
-47
lines changed

src/adaptors/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ impl<I, F> fmt::Debug for Batching<I, F> where I: fmt::Debug {
370370

371371
/// Create a new Batching iterator.
372372
pub fn batching<I, F>(iter: I, f: F) -> Batching<I, F> {
373-
Batching { f: f, iter: iter }
373+
Batching { f, iter }
374374
}
375375

376376
impl<B, F, I> Iterator for Batching<I, F>
@@ -534,7 +534,7 @@ pub fn merge_by_new<I, J, F>(a: I, b: J, cmp: F) -> MergeBy<I::IntoIter, J::Into
534534
a: a.into_iter().peekable(),
535535
b: b.into_iter().peekable(),
536536
fused: None,
537-
cmp: cmp,
537+
cmp,
538538
}
539539
}
540540

@@ -655,9 +655,9 @@ pub fn coalesce<I, F>(mut iter: I, f: F) -> Coalesce<I, F>
655655
Coalesce {
656656
iter: CoalesceCore {
657657
last: iter.next(),
658-
iter: iter,
658+
iter,
659659
},
660-
f: f,
660+
f,
661661
}
662662
}
663663

@@ -725,7 +725,7 @@ pub fn dedup_by<I, Pred>(mut iter: I, dedup_pred: Pred) -> DedupBy<I, Pred>
725725
DedupBy {
726726
iter: CoalesceCore {
727727
last: iter.next(),
728-
iter: iter,
728+
iter,
729729
},
730730
dedup_pred,
731731
}
@@ -801,7 +801,7 @@ impl<'a, I, F> fmt::Debug for TakeWhileRef<'a, I, F>
801801
pub fn take_while_ref<I, F>(iter: &mut I, f: F) -> TakeWhileRef<I, F>
802802
where I: Iterator + Clone
803803
{
804-
TakeWhileRef { iter: iter, f: f }
804+
TakeWhileRef { iter, f }
805805
}
806806

807807
impl<'a, I, F> Iterator for TakeWhileRef<'a, I, F>
@@ -843,7 +843,7 @@ pub struct WhileSome<I> {
843843

844844
/// Create a new `WhileSome<I>`.
845845
pub fn while_some<I>(iter: I) -> WhileSome<I> {
846-
WhileSome { iter: iter }
846+
WhileSome { iter }
847847
}
848848

849849
impl<I, A> Iterator for WhileSome<I>
@@ -915,7 +915,7 @@ pub struct Tuple1Combination<I> {
915915

916916
impl<I> From<I> for Tuple1Combination<I> {
917917
fn from(iter: I) -> Self {
918-
Tuple1Combination { iter: iter }
918+
Tuple1Combination { iter }
919919
}
920920
}
921921

@@ -1007,7 +1007,7 @@ pub struct MapInto<I, R> {
10071007
/// Create a new [`MapInto`](struct.MapInto.html) iterator.
10081008
pub fn map_into<I, R>(iter: I) -> MapInto<I, R> {
10091009
MapInto {
1010-
iter: iter,
1010+
iter,
10111011
_res: PhantomData,
10121012
}
10131013
}
@@ -1068,8 +1068,8 @@ pub fn map_results<I, F, T, U, E>(iter: I, f: F) -> MapResults<I, F>
10681068
F: FnMut(T) -> U,
10691069
{
10701070
MapResults {
1071-
iter: iter,
1072-
f: f,
1071+
iter,
1072+
f,
10731073
}
10741074
}
10751075

@@ -1119,8 +1119,8 @@ pub fn positions<I, F>(iter: I, f: F) -> Positions<I, F>
11191119
F: FnMut(I::Item) -> bool,
11201120
{
11211121
Positions {
1122-
iter: iter,
1123-
f: f,
1122+
iter,
1123+
f,
11241124
count: 0
11251125
}
11261126
}
@@ -1177,7 +1177,7 @@ where
11771177
I: Iterator,
11781178
F: FnMut(&mut I::Item),
11791179
{
1180-
Update { iter: iter, f: f }
1180+
Update { iter, f }
11811181
}
11821182

11831183
impl<I, F> Iterator for Update<I, F>

src/adaptors/multi_product.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<I> MultiProduct<I>
6565
let on_first_iter = match state {
6666
StartOfIter => {
6767
let on_first_iter = !last.in_progress();
68-
state = MidIter { on_first_iter: on_first_iter };
68+
state = MidIter { on_first_iter };
6969
on_first_iter
7070
},
7171
MidIter { on_first_iter } => on_first_iter

src/combinations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub fn combinations<I>(iter: I, k: usize) -> Combinations<I>
4040

4141
Combinations {
4242
indices: (0..k).collect(),
43-
pool: pool,
43+
pool,
4444
first: true,
4545
}
4646
}

src/combinations_with_replacement.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151
k,
5252
indices,
5353
max_index: 0,
54-
pool: pool,
54+
pool,
5555
first: true,
5656
}
5757
}

src/groupbylazy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl ChunkIndex {
3030
#[inline(always)]
3131
fn new(size: usize) -> Self {
3232
ChunkIndex {
33-
size: size,
33+
size,
3434
index: 0,
3535
key: 0,
3636
}
@@ -380,7 +380,7 @@ impl<'a, K, I, F> Iterator for Groups<'a, K, I, F>
380380
let key = inner.group_key(index);
381381
(key, Group {
382382
parent: self.parent,
383-
index: index,
383+
index,
384384
first: Some(elt),
385385
})
386386
})
@@ -528,7 +528,7 @@ impl<'a, I> Iterator for Chunks<'a, I>
528528
inner.step(index).map(|elt| {
529529
Chunk {
530530
parent: self.parent,
531-
index: index,
531+
index,
532532
first: Some(elt),
533533
}
534534
})

src/intersperse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn intersperse<I>(iter: I, elt: I::Item) -> Intersperse<I>
2727
let mut iter = iter.fuse();
2828
Intersperse {
2929
peek: iter.next(),
30-
iter: iter,
30+
iter,
3131
element: elt,
3232
}
3333
}

src/kmerge_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub fn kmerge_by<I, F>(iterable: I, mut less_than: F)
177177
let mut heap: Vec<_> = Vec::with_capacity(lower);
178178
heap.extend(iter.filter_map(|it| HeadTail::new(it.into_iter())));
179179
heapify(&mut heap, |a, b| less_than.kmerge_pred(&a.head, &b.head));
180-
KMergeBy { heap: heap, less_than: less_than }
180+
KMergeBy { heap, less_than }
181181
}
182182

183183
impl<I, F> Clone for KMergeBy<I, F>

src/lazy_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ where
1313
{
1414
pub fn new(it: I) -> LazyBuffer<I> {
1515
LazyBuffer {
16-
it: it,
16+
it,
1717
done: false,
1818
buffer: Vec::new(),
1919
}

src/merge_join.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn merge_join_by<I, J, F>(left: I, right: J, cmp_fn: F)
1717
MergeJoinBy {
1818
left: put_back(left.into_iter().fuse()),
1919
right: put_back(right.into_iter().fuse()),
20-
cmp_fn: cmp_fn
20+
cmp_fn,
2121
}
2222
}
2323

src/pad_tail.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ pub fn pad_using<I, F>(iter: I, min: usize, filler: F) -> PadUsing<I, F>
2323
{
2424
PadUsing {
2525
iter: iter.fuse(),
26-
min: min,
26+
min,
2727
pos: 0,
28-
filler: filler,
28+
filler,
2929
}
3030
}
3131

0 commit comments

Comments
 (0)