}
// 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;
}
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 }
(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 }
(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 }
(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 }
(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 }
(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 }
(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 }