pub struct Condition(/* private fields */);Expand description
A set of states, written as a conjunction of constraints. Variables it doesn’t mention are unconstrained.
Invariant: a stored constraint is never a variable’s full domain, so “mentioned” always
means “narrowed”. Condition::constrain keeps that true; the other operations preserve it.
Implementations§
Source§impl Condition
impl Condition
pub fn new() -> Self
Sourcepub fn is_unconstrained(&self) -> bool
pub fn is_unconstrained(&self) -> bool
No constraints at all: every state.
pub fn get(&self, v: VarId) -> Option<&Constraint>
pub fn iter(&self) -> impl Iterator<Item = (VarId, &Constraint)> + '_
pub fn vars(&self) -> impl Iterator<Item = VarId> + '_
Sourcepub fn constrain(&mut self, var: &Variable, c: Constraint)
pub fn constrain(&mut self, var: &Variable, c: Constraint)
Narrow var to c (on top of anything already required of it).
Sourcepub fn set(&mut self, var: &Variable, c: Constraint)
pub fn set(&mut self, var: &Variable, c: Constraint)
Replace whatever is required of var with c.
Sourcepub fn is_satisfiable(&self) -> bool
pub fn is_satisfiable(&self) -> bool
Does any state satisfy it?
Sourcepub fn overlay(&self, o: &Condition) -> Condition
pub fn overlay(&self, o: &Condition) -> Condition
self with o’s variables replaced by what o says: the state after an action that
sets those variables, leaving the rest alone.
Sourcepub fn contradictions(&self, o: &Condition) -> Vec<VarId>
pub fn contradictions(&self, o: &Condition) -> Vec<VarId>
Variables both mention but on which they can’t both hold.
Sourcepub fn restrict(&self, vars: impl IntoIterator<Item = VarId>) -> Condition
pub fn restrict(&self, vars: impl IntoIterator<Item = VarId>) -> Condition
Only the given variables.
Trait Implementations§
impl Eq for Condition
impl StructuralPartialEq for Condition
Auto Trait Implementations§
impl Freeze for Condition
impl RefUnwindSafe for Condition
impl Send for Condition
impl Sync for Condition
impl Unpin for Condition
impl UnsafeUnpin for Condition
impl UnwindSafe for Condition
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