about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorblake2-ppc <blake2-ppc>2013-08-08 22:07:21 +0200
committerblake2-ppc <blake2-ppc>2013-08-08 22:07:21 +0200
commite0b08533b4ffa73185fb6f510873ad57a56dac30 (patch)
treed4f625ebf5a74414ed25b5cb6bbfe6ce262db092 /src/libstd
parenta2e3cdfc362e27152bb6a3ad6ba0cefc13f061a9 (diff)
downloadrust-e0b08533b4ffa73185fb6f510873ad57a56dac30.tar.gz
rust-e0b08533b4ffa73185fb6f510873ad57a56dac30.zip
std: Implement traits for the one-tuple
(A,) did not have the trait implementations of 2- to 12- tuples.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/prelude.rs1
-rw-r--r--src/libstd/tuple.rs44
2 files changed, 25 insertions, 20 deletions
diff --git a/src/libstd/prelude.rs b/src/libstd/prelude.rs
index 65db55297b3..bf4c67e1091 100644
--- a/src/libstd/prelude.rs
+++ b/src/libstd/prelude.rs
@@ -69,6 +69,7 @@ pub use from_str::FromStr;
 pub use to_bytes::IterBytes;
 pub use to_str::{ToStr, ToStrConsume};
 pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
+pub use tuple::{CloneableTuple1, ImmutableTuple1};
 pub use tuple::{CloneableTuple2, CloneableTuple3, CloneableTuple4, CloneableTuple5};
 pub use tuple::{CloneableTuple6, CloneableTuple7, CloneableTuple8, CloneableTuple9};
 pub use tuple::{CloneableTuple10, CloneableTuple11, CloneableTuple12};
diff --git a/src/libstd/tuple.rs b/src/libstd/tuple.rs
index 41af29022a6..3dc7f65b3ad 100644
--- a/src/libstd/tuple.rs
+++ b/src/libstd/tuple.rs
@@ -148,7 +148,7 @@ macro_rules! tuple_impls {
                     $(fn $get_fn(&self) -> $T;)+
                 }
 
-                impl<$($T:Clone),+> $cloneable_trait<$($T),+> for ($($T),+) {
+                impl<$($T:Clone),+> $cloneable_trait<$($T),+> for ($($T,)+) {
                     $(
                         #[inline]
                         fn $get_fn(&self) -> $T {
@@ -161,7 +161,7 @@ macro_rules! tuple_impls {
                     $(fn $get_ref_fn<'a>(&'a self) -> &'a $T;)+
                 }
 
-                impl<$($T),+> $immutable_trait<$($T),+> for ($($T),+) {
+                impl<$($T),+> $immutable_trait<$($T),+> for ($($T,)+) {
                     $(
                         #[inline]
                         fn $get_ref_fn<'a>(&'a self) -> &'a $T {
@@ -170,59 +170,59 @@ macro_rules! tuple_impls {
                     )+
                 }
 
-                impl<$($T:Clone),+> Clone for ($($T),+) {
-                    fn clone(&self) -> ($($T),+) {
-                        ($(self.$get_ref_fn().clone()),+)
+                impl<$($T:Clone),+> Clone for ($($T,)+) {
+                    fn clone(&self) -> ($($T,)+) {
+                        ($(self.$get_ref_fn().clone(),)+)
                     }
                 }
 
                 #[cfg(not(test))]
-                impl<$($T:Eq),+> Eq for ($($T),+) {
+                impl<$($T:Eq),+> Eq for ($($T,)+) {
                     #[inline]
-                    fn eq(&self, other: &($($T),+)) -> bool {
+                    fn eq(&self, other: &($($T,)+)) -> bool {
                         $(*self.$get_ref_fn() == *other.$get_ref_fn())&&+
                     }
                     #[inline]
-                    fn ne(&self, other: &($($T),+)) -> bool {
+                    fn ne(&self, other: &($($T,)+)) -> bool {
                         !(*self == *other)
                     }
                 }
 
                 #[cfg(not(test))]
-                impl<$($T:TotalEq),+> TotalEq for ($($T),+) {
+                impl<$($T:TotalEq),+> TotalEq for ($($T,)+) {
                     #[inline]
-                    fn equals(&self, other: &($($T),+)) -> bool {
+                    fn equals(&self, other: &($($T,)+)) -> bool {
                         $(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+
                     }
                 }
 
                 #[cfg(not(test))]
-                impl<$($T:Ord),+> Ord for ($($T),+) {
+                impl<$($T:Ord),+> Ord for ($($T,)+) {
                     #[inline]
-                    fn lt(&self, other: &($($T),+)) -> bool {
+                    fn lt(&self, other: &($($T,)+)) -> bool {
                         lexical_lt!($(self.$get_ref_fn(), other.$get_ref_fn()),+)
                     }
                     #[inline]
-                    fn le(&self, other: &($($T),+)) -> bool { !(*other).lt(&(*self)) }
+                    fn le(&self, other: &($($T,)+)) -> bool { !(*other).lt(&(*self)) }
                     #[inline]
-                    fn ge(&self, other: &($($T),+)) -> bool { !(*self).lt(other) }
+                    fn ge(&self, other: &($($T,)+)) -> bool { !(*self).lt(other) }
                     #[inline]
-                    fn gt(&self, other: &($($T),+)) -> bool { (*other).lt(&(*self)) }
+                    fn gt(&self, other: &($($T,)+)) -> bool { (*other).lt(&(*self)) }
                 }
 
                 #[cfg(not(test))]
-                impl<$($T:TotalOrd),+> TotalOrd for ($($T),+) {
+                impl<$($T:TotalOrd),+> TotalOrd for ($($T,)+) {
                     #[inline]
-                    fn cmp(&self, other: &($($T),+)) -> Ordering {
+                    fn cmp(&self, other: &($($T,)+)) -> Ordering {
                         lexical_cmp!($(self.$get_ref_fn(), other.$get_ref_fn()),+)
                     }
                 }
 
                 #[cfg(not(test))]
-                impl<$($T:Zero),+> Zero for ($($T),+) {
+                impl<$($T:Zero),+> Zero for ($($T,)+) {
                     #[inline]
-                    fn zero() -> ($($T),+) {
-                        ($(Zero::zero::<$T>()),+)
+                    fn zero() -> ($($T,)+) {
+                        ($(Zero::zero::<$T>(),)+)
                     }
                     #[inline]
                     fn is_zero(&self) -> bool {
@@ -259,6 +259,10 @@ macro_rules! lexical_cmp {
 
 
 tuple_impls! {
+    (CloneableTuple1, ImmutableTuple1) {
+        (n0, n0_ref) -> A { (ref a,) => a }
+    }
+
     (CloneableTuple2, ImmutableTuple2) {
         (n0, n0_ref) -> A { (ref a,_) => a }
         (n1, n1_ref) -> B { (_,ref b) => b }