shacl_validation/
focus_nodes.rs

1use std::collections::HashSet;
2
3use srdf::Rdf;
4
5#[derive(Debug)]
6pub struct FocusNodes<S: Rdf>(HashSet<S::Term>);
7
8impl<S: Rdf> FocusNodes<S> {
9    pub fn new(iter: impl Iterator<Item = S::Term>) -> Self {
10        Self(HashSet::from_iter(iter))
11    }
12
13    pub fn is_empty(&self) -> bool {
14        self.0.is_empty()
15    }
16
17    pub fn len(&self) -> usize {
18        self.0.len()
19    }
20
21    pub fn iter(&self) -> impl Iterator<Item = &S::Term> {
22        self.0.iter()
23    }
24}
25
26impl<S: Rdf> Clone for FocusNodes<S> {
27    fn clone(&self) -> Self {
28        Self(self.0.clone())
29    }
30}
31
32impl<S: Rdf> Default for FocusNodes<S> {
33    fn default() -> Self {
34        Self(Default::default())
35    }
36}
37
38impl<S: Rdf> IntoIterator for FocusNodes<S> {
39    type Item = S::Term;
40    type IntoIter = std::collections::hash_set::IntoIter<S::Term>;
41
42    fn into_iter(self) -> Self::IntoIter {
43        self.0.into_iter()
44    }
45}