algae_graph/specs.rs
1/*
2 Appellation: specs <library>
3 Contrib: FL03 <jo3mccain@icloud.com>
4 Description: ... Summary ...
5*/
6
7pub trait Contain<T>
8where
9 T: PartialEq,
10{
11 /// [Contain::contains] returns true if the given element is in the [Contain] instance
12 fn contains(&self, elem: &T) -> bool;
13 /// [Contain::contains_all] returns true if all elements in the given iterator are in the [Contain] instance
14 fn contains_all(&self, iter: impl IntoIterator<Item = T>) -> bool {
15 iter.into_iter().all(|i| self.contains(&i))
16 }
17 /// [Contain::contains_some] returns true if any element in the given iterator is in the [Contain] instance
18 fn contains_some(&self, iter: impl IntoIterator<Item = T>) -> bool {
19 iter.into_iter().any(|i| self.contains(&i))
20 }
21}
22
23/// [Node] describes compatible vertices of the [crate::Graph]
24pub trait Node: Clone + Default + Eq + std::hash::Hash {}
25
26impl<T> Node for T where T: Clone + Default + Eq + std::hash::Hash {}
27
28pub trait Weight: Clone + PartialEq {}
29
30impl<T> Weight for T where T: Clone + PartialEq {}