]> git.lizzy.rs Git - rust.git/commitdiff
Merge ImmutableTuple* traits into their respective Tuple* trait
authorBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sun, 16 Feb 2014 09:25:28 +0000 (20:25 +1100)
committerBrendan Zabarauskas <bjzaba@yahoo.com.au>
Sun, 16 Feb 2014 09:25:28 +0000 (20:25 +1100)
src/libstd/prelude.rs
src/libstd/tuple.rs

index 3eaa1db87bafdc7464f06231190df99b4372fc30..ef159d68df7ea5a315042fdbd815f0c69da98c87 100644 (file)
@@ -68,9 +68,6 @@
 pub use to_bytes::IterBytes;
 pub use to_str::{ToStr, IntoStr};
 pub use tuple::{CloneableTuple, ImmutableTuple};
-pub use tuple::{ImmutableTuple1, ImmutableTuple2, ImmutableTuple3, ImmutableTuple4};
-pub use tuple::{ImmutableTuple5, ImmutableTuple6, ImmutableTuple7, ImmutableTuple8};
-pub use tuple::{ImmutableTuple9, ImmutableTuple10, ImmutableTuple11, ImmutableTuple12};
 pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
 pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
 pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
index f2d1144f281ee378248dd48ec1649bf111720d9f..18014fc17f918587f934dd16def94b1689a2d215 100644 (file)
@@ -80,36 +80,28 @@ fn second_ref<'a>(&'a self) -> &'a U {
 }
 
 // macro for implementing n-ary tuple functions and operations
-
 macro_rules! tuple_impls {
     ($(
-        ($move_trait:ident, $immutable_trait:ident) {
+        $Tuple:ident {
             $(($get_fn:ident, $get_ref_fn:ident) -> $T:ident {
                 $move_pattern:pat, $ref_pattern:pat => $ret:expr
             })+
         }
     )+) => {
         $(
-            pub trait $move_trait<$($T),+> {
+            pub trait $Tuple<$($T),+> {
                 $(fn $get_fn(self) -> $T;)+
+                $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+
             }
 
-            impl<$($T),+> $move_trait<$($T),+> for ($($T,)+) {
+            impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) {
                 $(
                     #[inline]
                     fn $get_fn(self) -> $T {
                         let $move_pattern = self;
                         $ret
                     }
-                )+
-            }
-
-            pub trait $immutable_trait<$($T),+> {
-                $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+
-            }
 
-            impl<$($T),+> $immutable_trait<$($T),+> for ($($T,)+) {
-                $(
                     #[inline]
                     fn $get_ref_fn<'a>(&'a self) -> &'a $T {
                         let $ref_pattern = *self;
@@ -230,37 +222,32 @@ macro_rules! write_tuple {
 }
 
 tuple_impls! {
-    (Tuple1, ImmutableTuple1) {
+    Tuple1 {
         (n0, n0_ref) -> A { (a,), (ref a,) => a }
     }
-
-    (Tuple2, ImmutableTuple2) {
+    Tuple2 {
         (n0, n0_ref) -> A { (a,_), (ref a,_) => a }
         (n1, n1_ref) -> B { (_,b), (_,ref b) => b }
     }
-
-    (Tuple3, ImmutableTuple3) {
+    Tuple3 {
         (n0, n0_ref) -> A { (a,_,_), (ref a,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_), (_,ref b,_) => b }
         (n2, n2_ref) -> C { (_,_,c), (_,_,ref c) => c }
     }
-
-    (Tuple4, ImmutableTuple4) {
+    Tuple4 {
         (n0, n0_ref) -> A { (a,_,_,_), (ref a,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_), (_,ref b,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_), (_,_,ref c,_) => c }
         (n3, n3_ref) -> D { (_,_,_,d), (_,_,_,ref d) => d }
     }
-
-    (Tuple5, ImmutableTuple5) {
+    Tuple5 {
         (n0, n0_ref) -> A { (a,_,_,_,_), (ref a,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_), (_,ref b,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_), (_,_,ref c,_,_) => c }
         (n3, n3_ref) -> D { (_,_,_,d,_), (_,_,_,ref d,_) => d }
         (n4, n4_ref) -> E { (_,_,_,_,e), (_,_,_,_,ref e) => e }
     }
-
-    (Tuple6, ImmutableTuple6) {
+    Tuple6 {
         (n0, n0_ref) -> A { (a,_,_,_,_,_), (ref a,_,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_,_), (_,ref b,_,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_,_), (_,_,ref c,_,_,_) => c }
@@ -268,8 +255,7 @@ macro_rules! write_tuple {
         (n4, n4_ref) -> E { (_,_,_,_,e,_), (_,_,_,_,ref e,_) => e }
         (n5, n5_ref) -> F { (_,_,_,_,_,f), (_,_,_,_,_,ref f) => f }
     }
-
-    (Tuple7, ImmutableTuple7) {
+    Tuple7 {
         (n0, n0_ref) -> A { (a,_,_,_,_,_,_), (ref a,_,_,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_,_,_), (_,ref b,_,_,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_,_,_), (_,_,ref c,_,_,_,_) => c }
@@ -278,8 +264,7 @@ macro_rules! write_tuple {
         (n5, n5_ref) -> F { (_,_,_,_,_,f,_), (_,_,_,_,_,ref f,_) => f }
         (n6, n6_ref) -> G { (_,_,_,_,_,_,g), (_,_,_,_,_,_,ref g) => g }
     }
-
-    (Tuple8, ImmutableTuple8) {
+    Tuple8 {
         (n0, n0_ref) -> A { (a,_,_,_,_,_,_,_), (ref a,_,_,_,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_,_,_,_), (_,ref b,_,_,_,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_,_,_,_), (_,_,ref c,_,_,_,_,_) => c }
@@ -289,8 +274,7 @@ macro_rules! write_tuple {
         (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_), (_,_,_,_,_,_,ref g,_) => g }
         (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h), (_,_,_,_,_,_,_,ref h) => h }
     }
-
-    (Tuple9, ImmutableTuple9) {
+    Tuple9 {
         (n0, n0_ref) -> A { (a,_,_,_,_,_,_,_,_), (ref a,_,_,_,_,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_,_,_,_,_), (_,ref b,_,_,_,_,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_,_,_,_,_), (_,_,ref c,_,_,_,_,_,_) => c }
@@ -301,8 +285,7 @@ macro_rules! write_tuple {
         (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h,_), (_,_,_,_,_,_,_,ref h,_) => h }
         (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i), (_,_,_,_,_,_,_,_,ref i) => i }
     }
-
-    (Tuple10, ImmutableTuple10) {
+    Tuple10 {
         (n0, n0_ref) -> A { (a,_,_,_,_,_,_,_,_,_), (ref a,_,_,_,_,_,_,_,_,_) => a }
         (n1, n1_ref) -> B { (_,b,_,_,_,_,_,_,_,_), (_,ref b,_,_,_,_,_,_,_,_) => b }
         (n2, n2_ref) -> C { (_,_,c,_,_,_,_,_,_,_), (_,_,ref c,_,_,_,_,_,_,_) => c }
@@ -314,8 +297,7 @@ macro_rules! write_tuple {
         (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i,_), (_,_,_,_,_,_,_,_,ref i,_) => i }
         (n9, n9_ref) -> J { (_,_,_,_,_,_,_,_,_,j), (_,_,_,_,_,_,_,_,_,ref j) => j }
     }
-
-    (Tuple11, ImmutableTuple11) {
+    Tuple11 {
         (n0,  n0_ref)  -> A { (a,_,_,_,_,_,_,_,_,_,_), (ref a,_,_,_,_,_,_,_,_,_,_) => a }
         (n1,  n1_ref)  -> B { (_,b,_,_,_,_,_,_,_,_,_), (_,ref b,_,_,_,_,_,_,_,_,_) => b }
         (n2,  n2_ref)  -> C { (_,_,c,_,_,_,_,_,_,_,_), (_,_,ref c,_,_,_,_,_,_,_,_) => c }
@@ -328,8 +310,7 @@ macro_rules! write_tuple {
         (n9,  n9_ref)  -> J { (_,_,_,_,_,_,_,_,_,j,_), (_,_,_,_,_,_,_,_,_,ref j,_) => j }
         (n10, n10_ref) -> K { (_,_,_,_,_,_,_,_,_,_,k), (_,_,_,_,_,_,_,_,_,_,ref k) => k }
     }
-
-    (Tuple12, ImmutableTuple12) {
+    Tuple12 {
         (n0,  n0_ref)  -> A { (a,_,_,_,_,_,_,_,_,_,_,_), (ref a,_,_,_,_,_,_,_,_,_,_,_) => a }
         (n1,  n1_ref)  -> B { (_,b,_,_,_,_,_,_,_,_,_,_), (_,ref b,_,_,_,_,_,_,_,_,_,_) => b }
         (n2,  n2_ref)  -> C { (_,_,c,_,_,_,_,_,_,_,_,_), (_,_,ref c,_,_,_,_,_,_,_,_,_) => c }