diff --git a/src/libcollections/btree.rs b/src/libcollections/btree.rs index 34aee6459a809..13b39da0756e0 100644 --- a/src/libcollections/btree.rs +++ b/src/libcollections/btree.rs @@ -500,15 +500,15 @@ impl Branch { let new_outcome = self.clone().rightmost_child.insert(k.clone(), v.clone(), ub.clone()); - new_branch = new_outcome.clone().n0(); - outcome = new_outcome.n1(); + new_branch = new_outcome.clone().val0(); + outcome = new_outcome.val1(); } else { let new_outcome = self.clone().elts[index.unwrap()].left.insert(k.clone(), v.clone(), ub.clone()); - new_branch = new_outcome.clone().n0(); - outcome = new_outcome.n1(); + new_branch = new_outcome.clone().val0(); + outcome = new_outcome.val1(); } //Check to see whether a branch or a leaf was returned from the //tree traversal. diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index c7c4aae35e3f3..11f801550856b 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1379,11 +1379,11 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result { match c.impls.find(&it.id) { Some(v) => { let mut non_trait = v.iter().filter(|p| { - p.n0_ref().trait_.is_none() + p.ref0().trait_.is_none() }); let non_trait = non_trait.to_owned_vec(); let mut traits = v.iter().filter(|p| { - p.n0_ref().trait_.is_some() + p.ref0().trait_.is_some() }); let traits = traits.to_owned_vec(); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index e9072fb37bb95..24c9d81e5308d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -262,7 +262,7 @@ fn rust_input(cratefile: &str, matches: &getopts::Matches) -> Output { let mut pm = plugins::PluginManager::new(Path::new(path)); for pass in passes.iter() { let plugin = match PASSES.iter().position(|&(p, _, _)| p == *pass) { - Some(i) => PASSES[i].n1(), + Some(i) => PASSES[i].val1(), None => { error!("unknown pass {}, skipping", *pass); continue diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs index 18014fc17f918..91625a53c9438 100644 --- a/src/libstd/tuple.rs +++ b/src/libstd/tuple.rs @@ -83,36 +83,43 @@ impl ImmutableTuple for (T, U) { macro_rules! tuple_impls { ($( $Tuple:ident { - $(($get_fn:ident, $get_ref_fn:ident) -> $T:ident { - $move_pattern:pat, $ref_pattern:pat => $ret:expr + $(($valN:ident, $refN:ident, $mutN:ident) -> $T:ident { + ($($x:ident),+) => $ret:expr })+ } )+) => { $( pub trait $Tuple<$($T),+> { - $(fn $get_fn(self) -> $T;)+ - $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+ + $(fn $valN(self) -> $T;)+ + $(fn $refN<'a>(&'a self) -> &'a $T;)+ + $(fn $mutN<'a>(&'a mut self) -> &'a mut $T;)+ } impl<$($T),+> $Tuple<$($T),+> for ($($T,)+) { $( #[inline] - fn $get_fn(self) -> $T { - let $move_pattern = self; - $ret + #[allow(unused_variable)] + fn $valN(self) -> $T { + let ($($x,)+) = self; $ret } #[inline] - fn $get_ref_fn<'a>(&'a self) -> &'a $T { - let $ref_pattern = *self; - $ret + #[allow(unused_variable)] + fn $refN<'a>(&'a self) -> &'a $T { + let ($(ref $x,)+) = *self; $ret + } + + #[inline] + #[allow(unused_variable)] + fn $mutN<'a>(&'a mut self) -> &'a mut $T { + let ($(ref mut $x,)+) = *self; $ret } )+ } impl<$($T:Clone),+> Clone for ($($T,)+) { fn clone(&self) -> ($($T,)+) { - ($(self.$get_ref_fn().clone(),)+) + ($(self.$refN().clone(),)+) } } @@ -120,11 +127,11 @@ macro_rules! tuple_impls { impl<$($T:Eq),+> Eq for ($($T,)+) { #[inline] fn eq(&self, other: &($($T,)+)) -> bool { - $(*self.$get_ref_fn() == *other.$get_ref_fn())&&+ + $(*self.$refN() == *other.$refN())&&+ } #[inline] fn ne(&self, other: &($($T,)+)) -> bool { - $(*self.$get_ref_fn() != *other.$get_ref_fn())||+ + $(*self.$refN() != *other.$refN())||+ } } @@ -132,7 +139,7 @@ macro_rules! tuple_impls { impl<$($T:TotalEq),+> TotalEq for ($($T,)+) { #[inline] fn equals(&self, other: &($($T,)+)) -> bool { - $(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+ + $(self.$refN().equals(other.$refN()))&&+ } } @@ -140,19 +147,19 @@ macro_rules! tuple_impls { impl<$($T:Ord + Eq),+> Ord for ($($T,)+) { #[inline] fn lt(&self, other: &($($T,)+)) -> bool { - lexical_ord!(lt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + lexical_ord!(lt, $(self.$refN(), other.$refN()),+) } #[inline] fn le(&self, other: &($($T,)+)) -> bool { - lexical_ord!(le, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + lexical_ord!(le, $(self.$refN(), other.$refN()),+) } #[inline] fn ge(&self, other: &($($T,)+)) -> bool { - lexical_ord!(ge, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + lexical_ord!(ge, $(self.$refN(), other.$refN()),+) } #[inline] fn gt(&self, other: &($($T,)+)) -> bool { - lexical_ord!(gt, $(self.$get_ref_fn(), other.$get_ref_fn()),+) + lexical_ord!(gt, $(self.$refN(), other.$refN()),+) } } @@ -160,7 +167,7 @@ macro_rules! tuple_impls { impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) { #[inline] fn cmp(&self, other: &($($T,)+)) -> Ordering { - lexical_cmp!($(self.$get_ref_fn(), other.$get_ref_fn()),+) + lexical_cmp!($(self.$refN(), other.$refN()),+) } } @@ -180,7 +187,7 @@ macro_rules! tuple_impls { impl<$($T: fmt::Show),+> fmt::Show for ($($T,)+) { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write_tuple!(f.buf, $(self.$get_ref_fn()),+) + write_tuple!(f.buf, $(self.$refN()),+) } } )+ @@ -223,106 +230,106 @@ macro_rules! write_tuple { tuple_impls! { Tuple1 { - (n0, n0_ref) -> A { (a,), (ref a,) => a } + (val0, ref0, mut0) -> A { (a) => a } } Tuple2 { - (n0, n0_ref) -> A { (a,_), (ref a,_) => a } - (n1, n1_ref) -> B { (_,b), (_,ref b) => b } + (val0, ref0, mut0) -> A { (a, b) => a } + (val1, ref1, mut1) -> B { (a, b) => b } } 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 } + (val0, ref0, mut0) -> A { (a, b, c) => a } + (val1, ref1, mut1) -> B { (a, b, c) => b } + (val2, ref2, mut2) -> C { (a, b, c) => c } } 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 } + (val0, ref0, mut0) -> A { (a, b, c, d) => a } + (val1, ref1, mut1) -> B { (a, b, c, d) => b } + (val2, ref2, mut2) -> C { (a, b, c, d) => c } + (val3, ref3, mut3) -> D { (a, b, c, d) => d } } 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 } + (val0, ref0, mut0) -> A { (a, b, c, d, e) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e) => e } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_), (_,_,_,ref d,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_), (_,_,_,_,ref e,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f), (_,_,_,_,_,ref f) => f } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f) => f } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_), (_,_,_,ref d,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_), (_,_,_,_,ref e,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_), (_,_,_,_,_,ref f,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g), (_,_,_,_,_,_,ref g) => g } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g) => g } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_,_), (_,_,_,ref d,_,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_,_), (_,_,_,_,ref e,_,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_,_), (_,_,_,_,_,ref f,_,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_), (_,_,_,_,_,_,ref g,_) => g } - (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h), (_,_,_,_,_,_,_,ref h) => h } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h) => g } + (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h) => h } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_,_,_), (_,_,_,ref d,_,_,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_,_,_), (_,_,_,_,ref e,_,_,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_,_,_), (_,_,_,_,_,ref f,_,_,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_,_), (_,_,_,_,_,_,ref g,_,_) => g } - (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h,_), (_,_,_,_,_,_,_,ref h,_) => h } - (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i), (_,_,_,_,_,_,_,_,ref i) => i } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i) => g } + (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i) => h } + (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i) => i } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_,_,_,_), (_,_,_,ref d,_,_,_,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_,_,_,_), (_,_,_,_,ref e,_,_,_,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_,_,_,_), (_,_,_,_,_,ref f,_,_,_,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_,_,_), (_,_,_,_,_,_,ref g,_,_,_) => g } - (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h,_,_), (_,_,_,_,_,_,_,ref h,_,_) => h } - (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i,_), (_,_,_,_,_,_,_,_,ref i,_) => i } - (n9, n9_ref) -> J { (_,_,_,_,_,_,_,_,_,j), (_,_,_,_,_,_,_,_,_,ref j) => j } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j) => g } + (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j) => h } + (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j) => i } + (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j) => j } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_,_,_,_,_), (_,_,_,ref d,_,_,_,_,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_,_,_,_,_), (_,_,_,_,ref e,_,_,_,_,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_,_,_,_,_), (_,_,_,_,_,ref f,_,_,_,_,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_,_,_,_), (_,_,_,_,_,_,ref g,_,_,_,_) => g } - (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h,_,_,_), (_,_,_,_,_,_,_,ref h,_,_,_) => h } - (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i,_,_), (_,_,_,_,_,_,_,_,ref i,_,_) => i } - (n9, n9_ref) -> J { (_,_,_,_,_,_,_,_,_,j,_), (_,_,_,_,_,_,_,_,_,ref j,_) => j } - (n10, n10_ref) -> K { (_,_,_,_,_,_,_,_,_,_,k), (_,_,_,_,_,_,_,_,_,_,ref k) => k } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k) => g } + (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k) => h } + (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k) => i } + (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k) => j } + (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k) => k } } 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 } - (n3, n3_ref) -> D { (_,_,_,d,_,_,_,_,_,_,_,_), (_,_,_,ref d,_,_,_,_,_,_,_,_) => d } - (n4, n4_ref) -> E { (_,_,_,_,e,_,_,_,_,_,_,_), (_,_,_,_,ref e,_,_,_,_,_,_,_) => e } - (n5, n5_ref) -> F { (_,_,_,_,_,f,_,_,_,_,_,_), (_,_,_,_,_,ref f,_,_,_,_,_,_) => f } - (n6, n6_ref) -> G { (_,_,_,_,_,_,g,_,_,_,_,_), (_,_,_,_,_,_,ref g,_,_,_,_,_) => g } - (n7, n7_ref) -> H { (_,_,_,_,_,_,_,h,_,_,_,_), (_,_,_,_,_,_,_,ref h,_,_,_,_) => h } - (n8, n8_ref) -> I { (_,_,_,_,_,_,_,_,i,_,_,_), (_,_,_,_,_,_,_,_,ref i,_,_,_) => i } - (n9, n9_ref) -> J { (_,_,_,_,_,_,_,_,_,j,_,_), (_,_,_,_,_,_,_,_,_,ref j,_,_) => j } - (n10, n10_ref) -> K { (_,_,_,_,_,_,_,_,_,_,k,_), (_,_,_,_,_,_,_,_,_,_,ref k,_) => k } - (n11, n11_ref) -> L { (_,_,_,_,_,_,_,_,_,_,_,l), (_,_,_,_,_,_,_,_,_,_,_,ref l) => l } + (val0, ref0, mut0) -> A { (a, b, c, d, e, f, g, h, i, j, k, l) => a } + (val1, ref1, mut1) -> B { (a, b, c, d, e, f, g, h, i, j, k, l) => b } + (val2, ref2, mut2) -> C { (a, b, c, d, e, f, g, h, i, j, k, l) => c } + (val3, ref3, mut3) -> D { (a, b, c, d, e, f, g, h, i, j, k, l) => d } + (val4, ref4, mut4) -> E { (a, b, c, d, e, f, g, h, i, j, k, l) => e } + (val5, ref5, mut5) -> F { (a, b, c, d, e, f, g, h, i, j, k, l) => f } + (val6, ref6, mut6) -> G { (a, b, c, d, e, f, g, h, i, j, k, l) => g } + (val7, ref7, mut7) -> H { (a, b, c, d, e, f, g, h, i, j, k, l) => h } + (val8, ref8, mut8) -> I { (a, b, c, d, e, f, g, h, i, j, k, l) => i } + (val9, ref9, mut9) -> J { (a, b, c, d, e, f, g, h, i, j, k, l) => j } + (val10, ref10, mut10) -> K { (a, b, c, d, e, f, g, h, i, j, k, l) => k } + (val11, ref11, mut11) -> L { (a, b, c, d, e, f, g, h, i, j, k, l) => l } } } @@ -355,33 +362,29 @@ mod tests { } #[test] - fn test_n_tuple() { - let t = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64); - assert_eq!(t.n0(), 0u8); - assert_eq!(t.n1(), 1u16); - assert_eq!(t.n2(), 2u32); - assert_eq!(t.n3(), 3u64); - assert_eq!(t.n4(), 4u); - assert_eq!(t.n5(), 5i8); - assert_eq!(t.n6(), 6i16); - assert_eq!(t.n7(), 7i32); - assert_eq!(t.n8(), 8i64); - assert_eq!(t.n9(), 9i); - assert_eq!(t.n10(), 10f32); - assert_eq!(t.n11(), 11f64); - - assert_eq!(t.n0_ref(), &0u8); - assert_eq!(t.n1_ref(), &1u16); - assert_eq!(t.n2_ref(), &2u32); - assert_eq!(t.n3_ref(), &3u64); - assert_eq!(t.n4_ref(), &4u); - assert_eq!(t.n5_ref(), &5i8); - assert_eq!(t.n6_ref(), &6i16); - assert_eq!(t.n7_ref(), &7i32); - assert_eq!(t.n8_ref(), &8i64); - assert_eq!(t.n9_ref(), &9i); - assert_eq!(t.n10_ref(), &10f32); - assert_eq!(t.n11_ref(), &11f64); + fn test_getters() { + macro_rules! test_getter( + ($x:expr, $valN:ident, $refN:ident, $mutN:ident, + $init:expr, $incr:expr, $result:expr) => ({ + assert_eq!($x.$valN(), $init); + assert_eq!(*$x.$refN(), $init); + *$x.$mutN() += $incr; + assert_eq!(*$x.$refN(), $result); + }) + ) + let mut x = (0u8, 1u16, 2u32, 3u64, 4u, 5i8, 6i16, 7i32, 8i64, 9i, 10f32, 11f64); + test_getter!(x, val0, ref0, mut0, 0, 1, 1); + test_getter!(x, val1, ref1, mut1, 1, 1, 2); + test_getter!(x, val2, ref2, mut2, 2, 1, 3); + test_getter!(x, val3, ref3, mut3, 3, 1, 4); + test_getter!(x, val4, ref4, mut4, 4, 1, 5); + test_getter!(x, val5, ref5, mut5, 5, 1, 6); + test_getter!(x, val6, ref6, mut6, 6, 1, 7); + test_getter!(x, val7, ref7, mut7, 7, 1, 8); + test_getter!(x, val8, ref8, mut8, 8, 1, 9); + test_getter!(x, val9, ref9, mut9, 9, 1, 10); + test_getter!(x, val10, ref10, mut10, 10.0, 1.0, 11.0); + test_getter!(x, val11, ref11, mut11, 11.0, 1.0, 12.0); } #[test] diff --git a/src/test/bench/shootout-fasta.rs b/src/test/bench/shootout-fasta.rs index 12e7862938625..f0c3517a0b88e 100644 --- a/src/test/bench/shootout-fasta.rs +++ b/src/test/bench/shootout-fasta.rs @@ -51,7 +51,7 @@ impl<'a> Iterator for AAGen<'a> { fn next(&mut self) -> Option { let r = self.rng.gen(); self.data.iter() - .skip_while(|pc| pc.n0() < r) + .skip_while(|pc| pc.val0() < r) .map(|&(_, c)| c) .next() }