pub struct Solver { /* private fields */ }Expand description
The Cassowary incremental constraint solver.
Call update_variables after all constraints
and suggestions have been applied, then read values with
value_of.
Implementations§
Source§impl Solver
impl Solver
Sourcepub fn add_constraint(
&mut self,
constraint: Constraint,
) -> Result<(), SolverError>
pub fn add_constraint( &mut self, constraint: Constraint, ) -> Result<(), SolverError>
Add a constraint to the solver.
Sourcepub fn remove_constraint(
&mut self,
constraint: &Constraint,
) -> Result<(), SolverError>
pub fn remove_constraint( &mut self, constraint: &Constraint, ) -> Result<(), SolverError>
Remove a previously added constraint.
Sourcepub fn add_edit_variable(
&mut self,
variable: &Variable,
strength: f64,
) -> Result<(), SolverError>
pub fn add_edit_variable( &mut self, variable: &Variable, strength: f64, ) -> Result<(), SolverError>
Register variable as an edit variable at the given strength.
Must be called before Solver::suggest_value. Strength must not be
Strength::REQUIRED.
Sourcepub fn suggest_value(
&mut self,
variable: &Variable,
value: f64,
) -> Result<(), SolverError>
pub fn suggest_value( &mut self, variable: &Variable, value: f64, ) -> Result<(), SolverError>
Suggest a value for a registered edit variable.
Sourcepub fn update_variables(&mut self)
pub fn update_variables(&mut self)
Populate cached variable values.
Call after all constraints and suggestions have been applied, then
read values with Solver::value_of.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Solver
impl RefUnwindSafe for Solver
impl Send for Solver
impl Sync for Solver
impl Unpin for Solver
impl UnsafeUnpin for Solver
impl UnwindSafe for Solver
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