refined_type/rule/empty/
number.rs1use crate::rule::EmptyDefinition;
2
3macro_rules! empty_definition {
4 ($t:ty) => {
5 impl $crate::rule::EmptyDefinition for $t {
6 fn empty(&self) -> bool {
7 *self == 0
8 }
9 }
10 };
11 ($t:ty, $($ts:ty), +) => {
12 empty_definition!($t);
13 empty_definition!($($ts), +);
14 };
15}
16
17empty_definition!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);
18
19impl EmptyDefinition for f32 {
20 fn empty(&self) -> bool {
21 *self == 0f32
22 }
23}
24
25impl EmptyDefinition for f64 {
26 fn empty(&self) -> bool {
27 *self == 0f64
28 }
29}