pub trait Constraint<Var, Value>: DynClone {
// Required methods
fn update(
&mut self,
assignment: &mut Assignment<Var, Value>,
key: fn(&Value) -> &str,
) -> Result<bool, ConstraintError<Var, Value>>;
fn pretty(&self) -> String;
}Expand description
A constraint that can be applied to variable assignments. Constraints are used in type inference to represent relationships between variables and values.
Required Methods§
Sourcefn update(
&mut self,
assignment: &mut Assignment<Var, Value>,
key: fn(&Value) -> &str,
) -> Result<bool, ConstraintError<Var, Value>>
fn update( &mut self, assignment: &mut Assignment<Var, Value>, key: fn(&Value) -> &str, ) -> Result<bool, ConstraintError<Var, Value>>
Updates the assignment based on this constraint. Returns Ok(true) if the assignment was modified, Ok(false) if no changes were made, or Err if the constraint cannot be satisfied.
update is allowed to modify the constraint itself, e.g. to convert a delayed constraint into an immediate one.
The key function gets a string representation of the value for display.