1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use std::{
    collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque},
    hash::Hash,
    rc::Rc,
    sync::Arc,
};

use dashmap::{DashMap, DashSet};

pub trait Empty {
    fn is_empty(&self) -> bool;
}

impl<T: Empty> Empty for Box<T> {
    fn is_empty(&self) -> bool {
        self.as_ref().is_empty()
    }
}

impl<T: Empty> Empty for Rc<T> {
    fn is_empty(&self) -> bool {
        self.as_ref().is_empty()
    }
}

impl<T: Empty> Empty for Arc<T> {
    fn is_empty(&self) -> bool {
        self.as_ref().is_empty()
    }
}

impl Empty for () {
    fn is_empty(&self) -> bool {
        true
    }
}

impl<V> Empty for Option<V> {
    fn is_empty(&self) -> bool {
        self.is_none()
    }
}

impl<V> Empty for Vec<V> {
    fn is_empty(&self) -> bool {
        Vec::is_empty(self)
    }
}

impl<V> Empty for VecDeque<V> {
    fn is_empty(&self) -> bool {
        VecDeque::is_empty(self)
    }
}

impl<V> Empty for LinkedList<V> {
    fn is_empty(&self) -> bool {
        LinkedList::is_empty(self)
    }
}

impl<V> Empty for BinaryHeap<V> {
    fn is_empty(&self) -> bool {
        BinaryHeap::is_empty(self)
    }
}

impl<K, V> Empty for BTreeMap<K, V> {
    fn is_empty(&self) -> bool {
        BTreeMap::is_empty(self)
    }
}

impl<V> Empty for BTreeSet<V> {
    fn is_empty(&self) -> bool {
        BTreeSet::is_empty(self)
    }
}

impl<K, V> Empty for HashMap<K, V> {
    fn is_empty(&self) -> bool {
        HashMap::is_empty(self)
    }
}

impl<V> Empty for HashSet<V> {
    fn is_empty(&self) -> bool {
        HashSet::is_empty(self)
    }
}

impl<K: Eq + Hash, V> Empty for DashMap<K, V> {
    fn is_empty(&self) -> bool {
        DashMap::is_empty(self)
    }
}

impl<K: Eq + Hash> Empty for DashSet<K> {
    fn is_empty(&self) -> bool {
        DashSet::is_empty(self)
    }
}