Trait Constraint

Source
pub trait Constraint {
    // Required methods
    fn vars<'a>(&'a self) -> Box<dyn Iterator<Item = &'a VarToken> + 'a>;
    fn substitute(
        &self,
        from: VarToken,
        to: VarToken,
    ) -> PsResult<Rc<dyn Constraint>>;

    // Provided methods
    fn on_assigned(
        &self,
        _search: &mut PuzzleSearch<'_>,
        _var: VarToken,
        _val: Val,
    ) -> PsResult<()> { ... }
    fn on_updated(&self, _search: &mut PuzzleSearch<'_>) -> PsResult<()> { ... }
}
Expand description

Constraint trait.

Required Methods§

Source

fn vars<'a>(&'a self) -> Box<dyn Iterator<Item = &'a VarToken> + 'a>

An iterator over the variables that are involved in the constraint.

Source

fn substitute( &self, from: VarToken, to: VarToken, ) -> PsResult<Rc<dyn Constraint>>

Substitute the “from” variable with the “to” variable.

Returns a new constraint with all instances of “from” replaced with “to”, or Err if a contradiction was found.

Provided Methods§

Source

fn on_assigned( &self, _search: &mut PuzzleSearch<'_>, _var: VarToken, _val: Val, ) -> PsResult<()>

Applied after a variable has been assigned.

Source

fn on_updated(&self, _search: &mut PuzzleSearch<'_>) -> PsResult<()>

Applied after a variable’s candidates has been modified.

Implementors§