pub struct Variable<D: Domain> {
pub domain: D,
/* private fields */
}Expand description
A CSP variable holding its current domain and an undo log for backtracking.
Fields§
§domain: DCurrent (working) domain – mutated during search.
Implementations§
Source§impl<D: Domain> Variable<D>
impl<D: Domain> Variable<D>
Sourcepub fn prune(&mut self, val: &D::Value, depth: usize) -> bool
pub fn prune(&mut self, val: &D::Value, depth: usize) -> bool
Record that val was pruned at depth, and remove it from the domain.
Returns true if the value was actually present and removed.
Sourcepub fn set_domain(&mut self, domain: D)
pub fn set_domain(&mut self, domain: D)
Replace the current domain entirely (used during initial propagation).
Sourcepub fn restrict_to(&mut self, val: &D::Value, depth: usize)
pub fn restrict_to(&mut self, val: &D::Value, depth: usize)
Restrict domain to a single value, recording all other removals at depth.
This is the fast path for backtracking assignment — avoids collecting
domain values into a Vec just to prune them.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for Variable<D>where
D: Freeze,
impl<D> RefUnwindSafe for Variable<D>
impl<D> Send for Variable<D>
impl<D> Sync for Variable<D>
impl<D> Unpin for Variable<D>
impl<D> UnsafeUnpin for Variable<D>where
D: UnsafeUnpin,
impl<D> UnwindSafe for Variable<D>
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