1pub trait Empty {
2 fn empty() -> Self;
3}
4
5macro_rules! numeric_empty_impl {
6 ($($t:ty)*) => ($(
7 impl Empty for $t {
8 fn empty() -> Self {
9 0
10 }
11 }
12 )*)
13}
14
15numeric_empty_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
16
17macro_rules! floating_numeric_empty_impl {
18 ($($t:ty)*) => ($(
19 impl Empty for $t {
20 fn empty() -> Self {
21 0.0
22 }
23 }
24 )*)
25}
26
27floating_numeric_empty_impl! { f32 f64 }
28
29impl<T> Empty for Vec<T> {
30 fn empty() -> Self {
31 Vec::empty()
32 }
33}
34
35impl Empty for String {
36 fn empty() -> Self {
37 String::empty()
38 }
39}