refined_type/rule/empty/
iterator.rs

1use crate::rule::EmptyDefinition;
2
3use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
4use std::iter::Map;
5
6impl<T> EmptyDefinition for Vec<T> {
7    fn empty(&self) -> bool {
8        self.is_empty()
9    }
10}
11
12impl<T> EmptyDefinition for std::vec::IntoIter<T> {
13    fn empty(&self) -> bool {
14        self.len() == 0
15    }
16}
17
18impl<'a, T> EmptyDefinition for std::slice::Iter<'a, T> {
19    fn empty(&self) -> bool {
20        self.len() == 0
21    }
22}
23
24impl<T> EmptyDefinition for VecDeque<T> {
25    fn empty(&self) -> bool {
26        self.is_empty()
27    }
28}
29
30impl<T> EmptyDefinition for std::collections::vec_deque::IntoIter<T> {
31    fn empty(&self) -> bool {
32        self.len() == 0
33    }
34}
35
36impl<'a, T> EmptyDefinition for std::collections::vec_deque::Iter<'a, T> {
37    fn empty(&self) -> bool {
38        self.len() == 0
39    }
40}
41
42impl<F, B, I: ExactSizeIterator> EmptyDefinition for Map<I, F>
43where
44    F: FnMut(I::Item) -> B,
45{
46    fn empty(&self) -> bool {
47        self.len() == 0
48    }
49}
50
51impl<T, S> EmptyDefinition for HashSet<T, S> {
52    fn empty(&self) -> bool {
53        self.is_empty()
54    }
55}
56
57impl<T> EmptyDefinition for std::collections::hash_set::IntoIter<T> {
58    fn empty(&self) -> bool {
59        self.len() == 0
60    }
61}
62
63impl<'a, T> EmptyDefinition for std::collections::hash_set::Iter<'a, T> {
64    fn empty(&self) -> bool {
65        self.len() == 0
66    }
67}
68
69impl<K, V, S> EmptyDefinition for HashMap<K, V, S> {
70    fn empty(&self) -> bool {
71        self.is_empty()
72    }
73}
74
75impl<K, V> EmptyDefinition for std::collections::hash_map::IntoIter<K, V> {
76    fn empty(&self) -> bool {
77        self.len() == 0
78    }
79}
80
81impl<'a, K, V> EmptyDefinition for std::collections::hash_map::Iter<'a, K, V> {
82    fn empty(&self) -> bool {
83        self.len() == 0
84    }
85}
86
87impl<T> EmptyDefinition for BTreeSet<T> {
88    fn empty(&self) -> bool {
89        self.is_empty()
90    }
91}
92
93impl<K, V> EmptyDefinition for BTreeMap<K, V> {
94    fn empty(&self) -> bool {
95        self.is_empty()
96    }
97}