1
Fork 0

Add Zero impls for lots of common types

This commit is contained in:
Alex Crichton 2013-06-14 18:27:52 -07:00
parent 07f5ab1009
commit 893c70d7bc
6 changed files with 63 additions and 2 deletions

View file

@ -135,6 +135,7 @@ macro_rules! tuple_impls {
pub mod inner {
use clone::Clone;
#[cfg(not(test))] use cmp::*;
#[cfg(not(test))] use num::Zero;
$(
pub trait $cloneable_trait<$($T),+> {
@ -210,6 +211,18 @@ macro_rules! tuple_impls {
lexical_cmp!($(self.$get_ref_fn(), other.$get_ref_fn()),+)
}
}
#[cfg(not(test))]
impl<$($T:Zero),+> Zero for ($($T),+) {
#[inline]
fn zero() -> ($($T),+) {
($(Zero::zero::<$T>()),+)
}
#[inline]
fn is_zero(&self) -> bool {
$(self.$get_ref_fn().is_zero())&&+
}
}
)+
}
}