shex_validation/
rule.rs

1use std::hash::Hash;
2
3use crate::Atom;
4
5#[derive(PartialEq, Clone, Debug)]
6pub struct Rule<A>
7where
8    A: Hash + Eq,
9{
10    head: Atom<A>,
11    body: Vec<Atom<A>>,
12}
13
14impl<A> Rule<A>
15where
16    A: Hash + Eq + Clone,
17{
18    pub fn new(head: Atom<A>, body: Vec<Atom<A>>) -> Rule<A> {
19        Rule { head, body }
20    }
21
22    /*
23    /// A fact is a rule with an empty body
24    fn fact(a: Atom<A>) -> Rule<A> {
25        Rule {
26            head: a,
27            body: Vec::new(),
28        }
29    }
30
31    fn with_solved(&mut self, a: Atom<A>) -> &Self {
32        // If the atom is in the body, remove it
33        if let Some(index) = self.body.iter().position(|value| *value == a) {
34            self.body.swap_remove(index);
35        }
36        self
37    }*/
38}