]> git.lizzy.rs Git - rust.git/commitdiff
Use match instead of intermediate variable
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sat, 18 May 2013 12:18:23 +0000 (22:18 +1000)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sat, 18 May 2013 16:19:16 +0000 (02:19 +1000)
src/libcore/tuple.rs

index 27632acf4e8f33eebe8e102267c05048885a1386..d5187c55730f1fe80e076609dff24f5f58d74032 100644 (file)
@@ -22,26 +22,28 @@ pub trait CopyableTuple<T, U> {
 }
 
 impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
-
     /// Return the first element of self
     #[inline(always)]
     fn first(&self) -> T {
-        let (t, _) = *self;
-        return t;
+        match *self {
+            (t, _) => t,
+        }
     }
 
     /// Return the second element of self
     #[inline(always)]
     fn second(&self) -> U {
-        let (_, u) = *self;
-        return u;
+        match *self {
+            (_, u) => u,
+        }
     }
 
     /// Return the results of swapping the two elements of self
     #[inline(always)]
     fn swap(&self) -> (U, T) {
-        let (t, u) = *self;
-        return (u, t);
+        match *self {
+            (t, u) => (u, t),
+        }
     }
 }