Skip to content

Commit 2c487f0

Browse files
Use Self
Two simple steps: - run `cargo clippy --fix -- -D clippy::use_self` - In `either_or_both`, remove `Self::` as glob use is quite convenient. https://rust-lang.github.io/rust-clippy/master/index.html#/use_self Co-Authored-By: Marcel Hellwig <ghpub@cookiesoft.de>
1 parent a22553e commit 2c487f0

File tree

16 files changed

+53
-53
lines changed

16 files changed

+53
-53
lines changed

benches/extra/zipslices.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ where
5858
#[inline(always)]
5959
pub fn from_slices(a: T, b: U) -> Self {
6060
let minl = cmp::min(a.len(), b.len());
61-
ZipSlices {
61+
Self {
6262
t: a,
6363
u: b,
6464
len: minl,

examples/iris.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum ParseError {
2525

2626
impl From<ParseFloatError> for ParseError {
2727
fn from(err: ParseFloatError) -> Self {
28-
ParseError::Numeric(err)
28+
Self::Numeric(err)
2929
}
3030
}
3131

@@ -34,7 +34,7 @@ impl FromStr for Iris {
3434
type Err = ParseError;
3535

3636
fn from_str(s: &str) -> Result<Self, Self::Err> {
37-
let mut iris = Iris {
37+
let mut iris = Self {
3838
name: "".into(),
3939
data: [0.; 4],
4040
};

src/adaptors/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ where
218218
/// Split the `PutBack` into its parts.
219219
#[inline]
220220
pub fn into_parts(self) -> (Option<I::Item>, I) {
221-
let PutBack { top, iter } = self;
221+
let Self { top, iter } = self;
222222
(top, iter)
223223
}
224224

@@ -689,7 +689,7 @@ pub struct Tuple1Combination<I> {
689689

690690
impl<I> From<I> for Tuple1Combination<I> {
691691
fn from(iter: I) -> Self {
692-
Tuple1Combination { iter }
692+
Self { iter }
693693
}
694694
}
695695

src/adaptors/multi_product.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ where
9595

9696
if last.in_progress() {
9797
true
98-
} else if MultiProduct::iterate_last(rest, state) {
98+
} else if Self::iterate_last(rest, state) {
9999
last.reset();
100100
last.iterate();
101101
// If iterator is None twice consecutively, then iterator is
@@ -139,7 +139,7 @@ where
139139
I::Item: Clone,
140140
{
141141
fn new(iter: I) -> Self {
142-
MultiProductIter {
142+
Self {
143143
cur: None,
144144
iter: iter.clone(),
145145
iter_orig: iter,
@@ -171,7 +171,7 @@ where
171171
type Item = Vec<I::Item>;
172172

173173
fn next(&mut self) -> Option<Self::Item> {
174-
if MultiProduct::iterate_last(&mut self.0, MultiProductIterState::StartOfIter) {
174+
if Self::iterate_last(&mut self.0, MultiProductIterState::StartOfIter) {
175175
Some(self.curr_iterator())
176176
} else {
177177
None

src/duplicates_impl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ mod private {
2222

2323
impl<I: Iterator, Key: Eq + Hash, F> DuplicatesBy<I, Key, F> {
2424
pub(crate) fn new(iter: I, key_method: F) -> Self {
25-
DuplicatesBy {
25+
Self {
2626
iter,
2727
meta: Meta {
2828
used: HashMap::new(),
@@ -77,7 +77,7 @@ mod private {
7777
type Item = I::Item;
7878

7979
fn next(&mut self) -> Option<Self::Item> {
80-
let DuplicatesBy { iter, meta } = self;
80+
let Self { iter, meta } = self;
8181
iter.find_map(|v| meta.filter(v))
8282
}
8383

@@ -109,7 +109,7 @@ mod private {
109109
F: KeyMethod<Key, I::Item>,
110110
{
111111
fn next_back(&mut self) -> Option<Self::Item> {
112-
let DuplicatesBy { iter, meta } = self;
112+
let Self { iter, meta } = self;
113113
iter.rev().find_map(|v| meta.filter(v))
114114
}
115115
}

src/either_or_both.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ impl<A, B> EitherOrBoth<A, B> {
301301
B: Default,
302302
{
303303
match self {
304-
EitherOrBoth::Left(l) => (l, B::default()),
305-
EitherOrBoth::Right(r) => (A::default(), r),
306-
EitherOrBoth::Both(l, r) => (l, r),
304+
Left(l) => (l, B::default()),
305+
Right(r) => (A::default(), r),
306+
Both(l, r) => (l, r),
307307
}
308308
}
309309

@@ -498,18 +498,18 @@ impl<T> EitherOrBoth<T, T> {
498498
impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B> {
499499
fn into(self) -> Option<Either<A, B>> {
500500
match self {
501-
EitherOrBoth::Left(l) => Some(Either::Left(l)),
502-
EitherOrBoth::Right(r) => Some(Either::Right(r)),
503-
_ => None,
501+
Left(l) => Some(Either::Left(l)),
502+
Right(r) => Some(Either::Right(r)),
503+
Both(..) => None,
504504
}
505505
}
506506
}
507507

508508
impl<A, B> From<Either<A, B>> for EitherOrBoth<A, B> {
509509
fn from(either: Either<A, B>) -> Self {
510510
match either {
511-
Either::Left(l) => EitherOrBoth::Left(l),
512-
Either::Right(l) => EitherOrBoth::Right(l),
511+
Either::Left(l) => Left(l),
512+
Either::Right(l) => Right(l),
513513
}
514514
}
515515
}

src/groupbylazy.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct ChunkIndex {
2929
impl ChunkIndex {
3030
#[inline(always)]
3131
fn new(size: usize) -> Self {
32-
ChunkIndex {
32+
Self {
3333
size,
3434
index: 0,
3535
key: 0,

src/kmerge_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ where
2727
I: Iterator,
2828
{
2929
/// Constructs a `HeadTail` from an `Iterator`. Returns `None` if the `Iterator` is empty.
30-
fn new(mut it: I) -> Option<HeadTail<I>> {
30+
fn new(mut it: I) -> Option<Self> {
3131
let head = it.next();
32-
head.map(|h| HeadTail { head: h, tail: it })
32+
head.map(|h| Self { head: h, tail: it })
3333
}
3434

3535
/// Get the next element and update `head`, returning the old head in `Some`.

src/lazy_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ impl<I> LazyBuffer<I>
1414
where
1515
I: Iterator,
1616
{
17-
pub fn new(it: I) -> LazyBuffer<I> {
18-
LazyBuffer {
17+
pub fn new(it: I) -> Self {
18+
Self {
1919
it: it.fuse(),
2020
buffer: Vec::new(),
2121
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,15 +4077,15 @@ impl<T> FoldWhile<T> {
40774077
/// Return the value in the continue or done.
40784078
pub fn into_inner(self) -> T {
40794079
match self {
4080-
FoldWhile::Continue(x) | FoldWhile::Done(x) => x,
4080+
Self::Continue(x) | Self::Done(x) => x,
40814081
}
40824082
}
40834083

40844084
/// Return true if `self` is `Done`, false if it is `Continue`.
40854085
pub fn is_done(&self) -> bool {
40864086
match *self {
4087-
FoldWhile::Continue(_) => false,
4088-
FoldWhile::Done(_) => true,
4087+
Self::Continue(_) => false,
4088+
Self::Done(_) => true,
40894089
}
40904090
}
40914091
}

0 commit comments

Comments
 (0)