pub struct Rule<Unbound, Bound> { /* private fields */ }Expand description
A human friendly-ish logical rule representation. Each rule represents an if-then statement (implication relationship). Statements in the rule may contain constants and/or variables. Constants are represented as Entity::Bound. Variables are represented as Entity::Unbound.
So that rules remain turing-incomplete, an invariant is upheld:
Unbound entities may not exists in the then clause unless they exist also in the if_all
clause.
Implementations§
Source§impl<'a, Unbound: Ord + Clone, Bound: Ord> Rule<Unbound, Bound>
impl<'a, Unbound: Ord + Clone, Bound: Ord> Rule<Unbound, Bound>
Sourcepub fn create(
if_all: Vec<[Entity<Unbound, Bound>; 4]>,
then: Vec<[Entity<Unbound, Bound>; 4]>,
) -> Result<Self, InvalidRule<Unbound>>
pub fn create( if_all: Vec<[Entity<Unbound, Bound>; 4]>, then: Vec<[Entity<Unbound, Bound>; 4]>, ) -> Result<Self, InvalidRule<Unbound>>
This constructor ensures that any unbound element in then also exists somewhere
in if_all. If this is not the case the rule is invalid and the function will return
Err. Otherwise it will return Ok.
Trait Implementations§
Source§impl<Unbound: Ord, Bound: Ord> Ord for Rule<Unbound, Bound>
impl<Unbound: Ord, Bound: Ord> Ord for Rule<Unbound, Bound>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Unbound: PartialOrd, Bound: PartialOrd> PartialOrd for Rule<Unbound, Bound>
impl<Unbound: PartialOrd, Bound: PartialOrd> PartialOrd for Rule<Unbound, Bound>
impl<Unbound: Eq, Bound: Eq> Eq for Rule<Unbound, Bound>
impl<Unbound, Bound> StructuralPartialEq for Rule<Unbound, Bound>
Auto Trait Implementations§
impl<Unbound, Bound> Freeze for Rule<Unbound, Bound>
impl<Unbound, Bound> RefUnwindSafe for Rule<Unbound, Bound>where
Unbound: RefUnwindSafe,
Bound: RefUnwindSafe,
impl<Unbound, Bound> Send for Rule<Unbound, Bound>
impl<Unbound, Bound> Sync for Rule<Unbound, Bound>
impl<Unbound, Bound> Unpin for Rule<Unbound, Bound>
impl<Unbound, Bound> UnwindSafe for Rule<Unbound, Bound>where
Unbound: UnwindSafe,
Bound: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more