Skip to content

Commit ee4d11f

Browse files
committed
Use match instead of intermediate variable
1 parent ce1e211 commit ee4d11f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/libcore/tuple.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@ pub trait CopyableTuple<T, U> {
2222
}
2323

2424
impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
25-
2625
/// Return the first element of self
2726
#[inline(always)]
2827
fn first(&self) -> T {
29-
let (t, _) = *self;
30-
return t;
28+
match *self {
29+
(t, _) => t,
30+
}
3131
}
3232

3333
/// Return the second element of self
3434
#[inline(always)]
3535
fn second(&self) -> U {
36-
let (_, u) = *self;
37-
return u;
36+
match *self {
37+
(_, u) => u,
38+
}
3839
}
3940

4041
/// Return the results of swapping the two elements of self
4142
#[inline(always)]
4243
fn swap(&self) -> (U, T) {
43-
let (t, u) = *self;
44-
return (u, t);
44+
match *self {
45+
(t, u) => (u, t),
46+
}
4547
}
4648
}
4749

0 commit comments

Comments
 (0)