Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
pub trait Zero { fn is_zero(&self) -> bool; }

macro_rules! impl_dec_zero {
    ($($t:ty),*) => {$(
        impl Zero for $t { #[inline(always)] fn is_zero(&self) -> bool { *self == 0 } }
    )*}
}

impl_dec_zero!(usize, u8, u16, u32, u64,
               isize, i8, i16, i32, i64);

impl Zero for f32 {  fn is_zero(&self) -> bool { *self == 0. } }
impl Zero for f64 {  fn is_zero(&self) -> bool { *self == 0. } }

impl Zero for char { fn is_zero(&self) -> bool { *self == '\0' } }

impl<T: ?Sized> Zero for *const T {  fn is_zero(&self) -> bool { self.is_null() } }
impl<T: ?Sized> Zero for *mut   T {  fn is_zero(&self) -> bool { self.is_null() } }