Skip to content

Commit 16d5c41

Browse files
committed
fix clippy::enum_glob_use
1 parent 5a58e64 commit 16d5c41

File tree

2 files changed

+44
-48
lines changed

2 files changed

+44
-48
lines changed

src/adaptors/multi_product.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ impl<I> MultiProduct<I>
6969
multi_iters: &mut [MultiProductIter<I>],
7070
mut state: MultiProductIterState
7171
) -> bool {
72-
use self::MultiProductIterState::*;
73-
7472
if let Some((last, rest)) = multi_iters.split_last_mut() {
7573
let on_first_iter = match state {
76-
StartOfIter => {
74+
MultiProductIterState::StartOfIter => {
7775
let on_first_iter = !last.in_progress();
78-
state = MidIter { on_first_iter };
76+
state = MultiProductIterState::MidIter { on_first_iter };
7977
on_first_iter
8078
},
81-
MidIter { on_first_iter } => on_first_iter
79+
MultiProductIterState::MidIter { on_first_iter } => on_first_iter
8280
};
8381

8482
if !on_first_iter {
@@ -100,8 +98,8 @@ impl<I> MultiProduct<I>
10098
// Reached end of iterator list. On initialisation, return true.
10199
// At end of iteration (final iterator finishes), finish.
102100
match state {
103-
StartOfIter => false,
104-
MidIter { on_first_iter } => on_first_iter
101+
MultiProductIterState::StartOfIter => false,
102+
MultiProductIterState::MidIter { on_first_iter } => on_first_iter
105103
}
106104
}
107105
}

src/either_or_both.rs

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use crate::EitherOrBoth::*;
2-
31
use either::Either;
42

53
/// Value that either holds a single A or B, or both.
@@ -28,7 +26,7 @@ impl<A, B> EitherOrBoth<A, B> {
2826
/// Exclusive version of [`has_left`](EitherOrBoth::has_left).
2927
pub fn is_left(&self) -> bool {
3028
match *self {
31-
Left(_) => true,
29+
EitherOrBoth::Left(_) => true,
3230
_ => false,
3331
}
3432
}
@@ -37,7 +35,7 @@ impl<A, B> EitherOrBoth<A, B> {
3735
/// Exclusive version of [`has_right`](EitherOrBoth::has_right).
3836
pub fn is_right(&self) -> bool {
3937
match *self {
40-
Right(_) => true,
38+
EitherOrBoth::Right(_) => true,
4139
_ => false,
4240
}
4341
}
@@ -51,51 +49,51 @@ impl<A, B> EitherOrBoth<A, B> {
5149
/// If `Left`, or `Both`, return `Some` with the left value, otherwise, return `None`.
5250
pub fn left(self) -> Option<A> {
5351
match self {
54-
Left(left) | Both(left, _) => Some(left),
55-
_ => None,
52+
EitherOrBoth::Left(left) | EitherOrBoth::Both(left, _) => Some(left),
53+
EitherOrBoth::Right(_) => None,
5654
}
5755
}
5856

5957
/// If `Right`, or `Both`, return `Some` with the right value, otherwise, return `None`.
6058
pub fn right(self) -> Option<B> {
6159
match self {
62-
Right(right) | Both(_, right) => Some(right),
63-
_ => None,
60+
EitherOrBoth::Right(right) | EitherOrBoth::Both(_, right) => Some(right),
61+
EitherOrBoth::Left(_) => None,
6462
}
6563
}
6664

6765
/// If Both, return `Some` tuple containing left and right.
6866
pub fn both(self) -> Option<(A, B)> {
6967
match self {
70-
Both(a, b) => Some((a, b)),
68+
EitherOrBoth::Both(a, b) => Some((a, b)),
7169
_ => None,
7270
}
7371
}
7472

7573
/// Converts from `&EitherOrBoth<A, B>` to `EitherOrBoth<&A, &B>`.
7674
pub fn as_ref(&self) -> EitherOrBoth<&A, &B> {
7775
match *self {
78-
Left(ref left) => Left(left),
79-
Right(ref right) => Right(right),
80-
Both(ref left, ref right) => Both(left, right),
76+
EitherOrBoth::Left(ref left) => EitherOrBoth::Left(left),
77+
EitherOrBoth::Right(ref right) => EitherOrBoth::Right(right),
78+
EitherOrBoth::Both(ref left, ref right) => EitherOrBoth::Both(left, right),
8179
}
8280
}
8381

8482
/// Converts from `&mut EitherOrBoth<A, B>` to `EitherOrBoth<&mut A, &mut B>`.
8583
pub fn as_mut(&mut self) -> EitherOrBoth<&mut A, &mut B> {
8684
match *self {
87-
Left(ref mut left) => Left(left),
88-
Right(ref mut right) => Right(right),
89-
Both(ref mut left, ref mut right) => Both(left, right),
85+
EitherOrBoth::Left(ref mut left) => EitherOrBoth::Left(left),
86+
EitherOrBoth::Right(ref mut right) => EitherOrBoth::Right(right),
87+
EitherOrBoth::Both(ref mut left, ref mut right) => EitherOrBoth::Both(left, right),
9088
}
9189
}
9290

9391
/// Convert `EitherOrBoth<A, B>` to `EitherOrBoth<B, A>`.
9492
pub fn flip(self) -> EitherOrBoth<B, A> {
9593
match self {
96-
Left(a) => Right(a),
97-
Right(b) => Left(b),
98-
Both(a, b) => Both(b, a),
94+
EitherOrBoth::Left(a) => EitherOrBoth::Right(a),
95+
EitherOrBoth::Right(b) => EitherOrBoth::Left(b),
96+
EitherOrBoth::Both(a, b) => EitherOrBoth::Both(b, a),
9997
}
10098
}
10199

@@ -106,9 +104,9 @@ impl<A, B> EitherOrBoth<A, B> {
106104
F: FnOnce(A) -> M,
107105
{
108106
match self {
109-
Both(a, b) => Both(f(a), b),
110-
Left(a) => Left(f(a)),
111-
Right(b) => Right(b),
107+
EitherOrBoth::Both(a, b) => EitherOrBoth::Both(f(a), b),
108+
EitherOrBoth::Left(a) => EitherOrBoth::Left(f(a)),
109+
EitherOrBoth::Right(b) => EitherOrBoth::Right(b),
112110
}
113111
}
114112

@@ -119,9 +117,9 @@ impl<A, B> EitherOrBoth<A, B> {
119117
F: FnOnce(B) -> M,
120118
{
121119
match self {
122-
Left(a) => Left(a),
123-
Right(b) => Right(f(b)),
124-
Both(a, b) => Both(a, f(b)),
120+
EitherOrBoth::Left(a) => EitherOrBoth::Left(a),
121+
EitherOrBoth::Right(b) => EitherOrBoth::Right(f(b)),
122+
EitherOrBoth::Both(a, b) => EitherOrBoth::Both(a, f(b)),
125123
}
126124
}
127125

@@ -134,9 +132,9 @@ impl<A, B> EitherOrBoth<A, B> {
134132
G: FnOnce(B) -> R,
135133
{
136134
match self {
137-
Left(a) => Left(f(a)),
138-
Right(b) => Right(g(b)),
139-
Both(a, b) => Both(f(a), g(b)),
135+
EitherOrBoth::Left(a) => EitherOrBoth::Left(f(a)),
136+
EitherOrBoth::Right(b) => EitherOrBoth::Right(g(b)),
137+
EitherOrBoth::Both(a, b) => EitherOrBoth::Both(f(a), g(b)),
140138
}
141139
}
142140

@@ -147,8 +145,8 @@ impl<A, B> EitherOrBoth<A, B> {
147145
F: FnOnce(A) -> EitherOrBoth<L, B>,
148146
{
149147
match self {
150-
Left(a) | Both(a, _) => f(a),
151-
Right(b) => Right(b),
148+
EitherOrBoth::Left(a) | EitherOrBoth::Both(a, _) => f(a),
149+
EitherOrBoth::Right(b) => EitherOrBoth::Right(b),
152150
}
153151
}
154152

@@ -159,8 +157,8 @@ impl<A, B> EitherOrBoth<A, B> {
159157
F: FnOnce(B) -> EitherOrBoth<A, R>,
160158
{
161159
match self {
162-
Left(a) => Left(a),
163-
Right(b) | Both(_, b) => f(b),
160+
EitherOrBoth::Left(a) => EitherOrBoth::Left(a),
161+
EitherOrBoth::Right(b) | EitherOrBoth::Both(_, b) => f(b),
164162
}
165163
}
166164

@@ -185,9 +183,9 @@ impl<A, B> EitherOrBoth<A, B> {
185183
/// ```
186184
pub fn or(self, l: A, r: B) -> (A, B) {
187185
match self {
188-
Left(inner_l) => (inner_l, r),
189-
Right(inner_r) => (l, inner_r),
190-
Both(inner_l, inner_r) => (inner_l, inner_r),
186+
EitherOrBoth::Left(inner_l) => (inner_l, r),
187+
EitherOrBoth::Right(inner_r) => (l, inner_r),
188+
EitherOrBoth::Both(inner_l, inner_r) => (inner_l, inner_r),
191189
}
192190
}
193191

@@ -222,9 +220,9 @@ impl<A, B> EitherOrBoth<A, B> {
222220
/// ```
223221
pub fn or_else<L: FnOnce() -> A, R: FnOnce() -> B>(self, l: L, r: R) -> (A, B) {
224222
match self {
225-
Left(inner_l) => (inner_l, r()),
226-
Right(inner_r) => (l(), inner_r),
227-
Both(inner_l, inner_r) => (inner_l, inner_r),
223+
EitherOrBoth::Left(inner_l) => (inner_l, r()),
224+
EitherOrBoth::Right(inner_r) => (l(), inner_r),
225+
EitherOrBoth::Both(inner_l, inner_r) => (inner_l, inner_r),
228226
}
229227
}
230228
}
@@ -236,9 +234,9 @@ impl<T> EitherOrBoth<T, T> {
236234
F: FnOnce(T, T) -> T,
237235
{
238236
match self {
239-
Left(a) => a,
240-
Right(b) => b,
241-
Both(a, b) => f(a, b),
237+
EitherOrBoth::Left(a) => a,
238+
EitherOrBoth::Right(b) => b,
239+
EitherOrBoth::Both(a, b) => f(a, b),
242240
}
243241
}
244242
}
@@ -248,7 +246,7 @@ impl<A, B> Into<Option<Either<A, B>>> for EitherOrBoth<A, B> {
248246
match self {
249247
EitherOrBoth::Left(l) => Some(Either::Left(l)),
250248
EitherOrBoth::Right(r) => Some(Either::Right(r)),
251-
_ => None,
249+
EitherOrBoth::Both(..) => None,
252250
}
253251
}
254252
}

0 commit comments

Comments
 (0)