Add Zero impls for lots of common types
This commit is contained in:
parent
07f5ab1009
commit
893c70d7bc
6 changed files with 63 additions and 2 deletions
|
@ -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())&&+
|
||||
}
|
||||
}
|
||||
)+
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue