deep_causality/extensions/assumable/
mod.rs1use std::collections::{BTreeMap, HashMap, VecDeque};
7use std::hash::Hash;
8
9use crate::{Assumable, AssumableReasoning};
11
12impl<T> AssumableReasoning<T> for [T]
16where
17 T: Assumable,
18{
19 fn len(&self) -> usize {
20 <[T]>::len(self)
21 }
22 fn is_empty(&self) -> bool {
23 <[T]>::is_empty(self)
24 }
25 fn get_all_items(&self) -> Vec<&T> {
26 self.iter().collect()
27 }
28}
29
30impl<T> AssumableReasoning<T> for Vec<T>
34where
35 T: Assumable,
36{
37 fn len(&self) -> usize {
38 Vec::len(self)
39 }
40 fn is_empty(&self) -> bool {
41 Vec::is_empty(self)
42 }
43 fn get_all_items(&self) -> Vec<&T> {
44 self.iter().collect()
45 }
46}
47
48impl<T> AssumableReasoning<T> for VecDeque<T>
52where
53 T: Assumable,
54{
55 fn len(&self) -> usize {
56 VecDeque::len(self)
57 }
58 fn is_empty(&self) -> bool {
59 VecDeque::is_empty(self)
60 }
61 fn get_all_items(&self) -> Vec<&T> {
62 self.iter().collect()
63 }
64}
65
66impl<K, V> AssumableReasoning<V> for HashMap<K, V>
70where
71 K: Eq + Hash,
72 V: Assumable,
73{
74 fn len(&self) -> usize {
75 HashMap::len(self)
76 }
77 fn is_empty(&self) -> bool {
78 HashMap::is_empty(self)
79 }
80 fn get_all_items(&self) -> Vec<&V> {
81 self.values().collect::<Vec<&V>>()
82 }
83}
84
85impl<K, V> AssumableReasoning<V> for BTreeMap<K, V>
89where
90 K: Ord,
91 V: Assumable,
92{
93 fn len(&self) -> usize {
94 BTreeMap::len(self)
95 }
96 fn is_empty(&self) -> bool {
97 BTreeMap::is_empty(self)
98 }
99 fn get_all_items(&self) -> Vec<&V> {
100 self.values().collect::<Vec<&V>>()
101 }
102}