lighthouse_protocol/utils/zero.rs
1/// A type that has a zero value.
2pub trait Zero {
3 /// The zero value.
4 const ZERO: Self;
5}
6
7macro_rules! impl_int_zero {
8 ($($tys:ty),*) => {
9 $(impl Zero for $tys {
10 const ZERO: Self = 0;
11 })*
12 };
13}
14
15macro_rules! impl_float_zero {
16 ($($tys:ty),*) => {
17 $(impl Zero for $tys {
18 const ZERO: Self = 0.0;
19 })*
20 };
21}
22
23impl_int_zero!(
24 u8, u16, u32, u64, u128, usize,
25 i8, i16, i32, i64, i128, isize
26);
27
28impl_float_zero!(
29 f32, f64
30);