Skip to content

Commit

Permalink
Merge #411
Browse files Browse the repository at this point in the history
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 <descpl@yahoo.de>
  • Loading branch information
bors[bot] and phimuemue committed Feb 16, 2020
2 parents f152f5e + 77c2f73 commit c620ae8
Show file tree
Hide file tree
Showing 18 changed files with 47 additions and 47 deletions.
28 changes: 14 additions & 14 deletions src/adaptors/mod.rs
Expand Up @@ -370,7 +370,7 @@ impl<I, F> fmt::Debug for Batching<I, F> where I: fmt::Debug {

/// Create a new Batching iterator.
pub fn batching<I, F>(iter: I, f: F) -> Batching<I, F> {
Batching { f: f, iter: iter }
Batching { f, iter }
}

impl<B, F, I> Iterator for Batching<I, F>
Expand Down Expand Up @@ -534,7 +534,7 @@ pub fn merge_by_new<I, J, F>(a: I, b: J, cmp: F) -> MergeBy<I::IntoIter, J::Into
a: a.into_iter().peekable(),
b: b.into_iter().peekable(),
fused: None,
cmp: cmp,
cmp,
}
}

Expand Down Expand Up @@ -655,9 +655,9 @@ pub fn coalesce<I, F>(mut iter: I, f: F) -> Coalesce<I, F>
Coalesce {
iter: CoalesceCore {
last: iter.next(),
iter: iter,
iter,
},
f: f,
f,
}
}

Expand Down Expand Up @@ -725,7 +725,7 @@ pub fn dedup_by<I, Pred>(mut iter: I, dedup_pred: Pred) -> DedupBy<I, Pred>
DedupBy {
iter: CoalesceCore {
last: iter.next(),
iter: iter,
iter,
},
dedup_pred,
}
Expand Down Expand Up @@ -801,7 +801,7 @@ impl<'a, I, F> fmt::Debug for TakeWhileRef<'a, I, F>
pub fn take_while_ref<I, F>(iter: &mut I, f: F) -> TakeWhileRef<I, F>
where I: Iterator + Clone
{
TakeWhileRef { iter: iter, f: f }
TakeWhileRef { iter, f }
}

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

/// Create a new `WhileSome<I>`.
pub fn while_some<I>(iter: I) -> WhileSome<I> {
WhileSome { iter: iter }
WhileSome { iter }
}

impl<I, A> Iterator for WhileSome<I>
Expand Down Expand Up @@ -915,7 +915,7 @@ pub struct Tuple1Combination<I> {

impl<I> From<I> for Tuple1Combination<I> {
fn from(iter: I) -> Self {
Tuple1Combination { iter: iter }
Tuple1Combination { iter }
}
}

Expand Down Expand Up @@ -1007,7 +1007,7 @@ pub struct MapInto<I, R> {
/// Create a new [`MapInto`](struct.MapInto.html) iterator.
pub fn map_into<I, R>(iter: I) -> MapInto<I, R> {
MapInto {
iter: iter,
iter,
_res: PhantomData,
}
}
Expand Down Expand Up @@ -1068,8 +1068,8 @@ pub fn map_results<I, F, T, U, E>(iter: I, f: F) -> MapResults<I, F>
F: FnMut(T) -> U,
{
MapResults {
iter: iter,
f: f,
iter,
f,
}
}

Expand Down Expand Up @@ -1119,8 +1119,8 @@ pub fn positions<I, F>(iter: I, f: F) -> Positions<I, F>
F: FnMut(I::Item) -> bool,
{
Positions {
iter: iter,
f: f,
iter,
f,
count: 0
}
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ where
I: Iterator,
F: FnMut(&mut I::Item),
{
Update { iter: iter, f: f }
Update { iter, f }
}

impl<I, F> Iterator for Update<I, F>
Expand Down
2 changes: 1 addition & 1 deletion src/adaptors/multi_product.rs
Expand Up @@ -65,7 +65,7 @@ impl<I> MultiProduct<I>
let on_first_iter = match state {
StartOfIter => {
let on_first_iter = !last.in_progress();
state = MidIter { on_first_iter: on_first_iter };
state = MidIter { on_first_iter };
on_first_iter
},
MidIter { on_first_iter } => on_first_iter
Expand Down
2 changes: 1 addition & 1 deletion src/combinations.rs
Expand Up @@ -40,7 +40,7 @@ pub fn combinations<I>(iter: I, k: usize) -> Combinations<I>

Combinations {
indices: (0..k).collect(),
pool: pool,
pool,
first: true,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/combinations_with_replacement.rs
Expand Up @@ -51,7 +51,7 @@ where
k,
indices,
max_index: 0,
pool: pool,
pool,
first: true,
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/groupbylazy.rs
Expand Up @@ -30,7 +30,7 @@ impl ChunkIndex {
#[inline(always)]
fn new(size: usize) -> Self {
ChunkIndex {
size: size,
size,
index: 0,
key: 0,
}
Expand Down Expand Up @@ -380,7 +380,7 @@ impl<'a, K, I, F> Iterator for Groups<'a, K, I, F>
let key = inner.group_key(index);
(key, Group {
parent: self.parent,
index: index,
index,
first: Some(elt),
})
})
Expand Down Expand Up @@ -528,7 +528,7 @@ impl<'a, I> Iterator for Chunks<'a, I>
inner.step(index).map(|elt| {
Chunk {
parent: self.parent,
index: index,
index,
first: Some(elt),
}
})
Expand Down
2 changes: 1 addition & 1 deletion src/intersperse.rs
Expand Up @@ -27,7 +27,7 @@ pub fn intersperse<I>(iter: I, elt: I::Item) -> Intersperse<I>
let mut iter = iter.fuse();
Intersperse {
peek: iter.next(),
iter: iter,
iter,
element: elt,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/kmerge_impl.rs
Expand Up @@ -177,7 +177,7 @@ pub fn kmerge_by<I, F>(iterable: I, mut less_than: F)
let mut heap: Vec<_> = Vec::with_capacity(lower);
heap.extend(iter.filter_map(|it| HeadTail::new(it.into_iter())));
heapify(&mut heap, |a, b| less_than.kmerge_pred(&a.head, &b.head));
KMergeBy { heap: heap, less_than: less_than }
KMergeBy { heap, less_than }
}

impl<I, F> Clone for KMergeBy<I, F>
Expand Down
2 changes: 1 addition & 1 deletion src/lazy_buffer.rs
Expand Up @@ -13,7 +13,7 @@ where
{
pub fn new(it: I) -> LazyBuffer<I> {
LazyBuffer {
it: it,
it,
done: false,
buffer: Vec::new(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/merge_join.rs
Expand Up @@ -17,7 +17,7 @@ pub fn merge_join_by<I, J, F>(left: I, right: J, cmp_fn: F)
MergeJoinBy {
left: put_back(left.into_iter().fuse()),
right: put_back(right.into_iter().fuse()),
cmp_fn: cmp_fn
cmp_fn,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/pad_tail.rs
Expand Up @@ -23,9 +23,9 @@ pub fn pad_using<I, F>(iter: I, min: usize, filler: F) -> PadUsing<I, F>
{
PadUsing {
iter: iter.fuse(),
min: min,
min,
pos: 0,
filler: filler,
filler,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/peeking_take_while.rs
Expand Up @@ -89,8 +89,8 @@ pub fn peeking_take_while<I, F>(iter: &mut I, f: F) -> PeekingTakeWhile<I, F>
where I: Iterator,
{
PeekingTakeWhile {
iter: iter,
f: f,
iter,
f,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/process_results_impl.rs
Expand Up @@ -75,7 +75,7 @@ pub fn process_results<I, F, T, E, R>(iterable: I, processor: F) -> Result<R, E>
let iter = iterable.into_iter();
let mut error = Ok(());

let result = processor(ProcessResults { error: &mut error, iter: iter });
let result = processor(ProcessResults { error: &mut error, iter });

error.map(|_| result)
}
4 changes: 2 additions & 2 deletions src/repeatn.rs
Expand Up @@ -14,9 +14,9 @@ pub fn repeat_n<A>(element: A, n: usize) -> RepeatN<A>
where A: Clone,
{
if n == 0 {
RepeatN { elt: None, n: n, }
RepeatN { elt: None, n, }
} else {
RepeatN { elt: Some(element), n: n, }
RepeatN { elt: Some(element), n, }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/sources.rs
Expand Up @@ -102,7 +102,7 @@ pub fn unfold<A, St, F>(initial_state: St, f: F) -> Unfold<St, F>
where F: FnMut(&mut St) -> Option<A>
{
Unfold {
f: f,
f,
state: initial_state,
}
}
Expand Down Expand Up @@ -186,6 +186,6 @@ pub fn iterate<St, F>(initial_value: St, f: F) -> Iterate<St, F>
{
Iterate {
state: initial_value,
f: f,
f,
}
}
2 changes: 1 addition & 1 deletion src/tee.rs
Expand Up @@ -28,7 +28,7 @@ pub struct Tee<I>
pub fn new<I>(iter: I) -> (Tee<I>, Tee<I>)
where I: Iterator
{
let buffer = TeeBuffer{backlog: VecDeque::new(), iter: iter, owner: false};
let buffer = TeeBuffer{backlog: VecDeque::new(), iter, owner: false};
let t1 = Tee{rcbuffer: Rc::new(RefCell::new(buffer)), id: true};
let t2 = Tee{rcbuffer: t1.rcbuffer.clone(), id: false};
(t1, t2)
Expand Down
6 changes: 3 additions & 3 deletions src/tuple_impl.rs
Expand Up @@ -32,7 +32,7 @@ impl<T> TupleBuffer<T>
fn new(buf: T::Buffer) -> Self {
TupleBuffer {
cur: 0,
buf: buf,
buf,
}
}
}
Expand Down Expand Up @@ -158,8 +158,8 @@ pub fn tuple_windows<I, T>(mut iter: I) -> TupleWindows<I, T>
}

TupleWindows {
last: last,
iter: iter,
last,
iter,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/unique_impl.rs
Expand Up @@ -30,9 +30,9 @@ pub fn unique_by<I, V, F>(iter: I, f: F) -> UniqueBy<I, V, F>
I: Iterator,
{
UniqueBy {
iter: iter,
iter,
used: HashMap::new(),
f: f,
f,
}
}

Expand Down Expand Up @@ -126,7 +126,7 @@ pub fn unique<I>(iter: I) -> Unique<I>
{
Unique {
iter: UniqueBy {
iter: iter,
iter,
used: HashMap::new(),
f: (),
}
Expand Down
14 changes: 7 additions & 7 deletions tests/quick.rs
Expand Up @@ -124,7 +124,7 @@ impl<T, HK> Iter<T, HK> where HK: HintKind
Iter {
iterator: it,
fuse_flag: 0,
hint_kind: hint_kind
hint_kind,
}
}
}
Expand Down Expand Up @@ -239,12 +239,12 @@ impl<HK> qc::Arbitrary for ShiftRange<HK>
let hint_kind = qc::Arbitrary::arbitrary(g);

ShiftRange {
range_start: range_start,
range_end: range_end,
start_step: start_step,
end_step: end_step,
iter_count: iter_count,
hint_kind: hint_kind
range_start,
range_end,
start_step,
end_step,
iter_count,
hint_kind,
}
}
}
Expand Down

0 comments on commit c620ae8

Please sign in to comment.