is_zero for hash types

This commit is contained in:
arkpar 2016-01-09 10:20:07 +01:00
parent 647ea286ba
commit 49d97d7cb3

View File

@ -30,6 +30,7 @@ pub trait FixedHash: Sized + BytesConvertable {
fn bloom_part<T>(&self, m: usize) -> T where T: FixedHash;
fn contains_bloom<T>(&self, b: &T) -> bool where T: FixedHash;
fn contains<'a>(&'a self, b: &'a Self) -> bool;
fn is_zero(&self) -> bool;
}
macro_rules! impl_hash {
@ -165,6 +166,10 @@ macro_rules! impl_hash {
fn contains<'a>(&'a self, b: &'a Self) -> bool {
&(b & self) == b
}
fn is_zero(&self) -> bool {
self.eq(&Self::new())
}
}
impl FromStr for $from {