Struct DiscreteConstraint

Source
pub struct DiscreteConstraint<V, T: Hash + Eq> { /* private fields */ }
Expand description

A generic form of Constraints on discrete variables.

§Note

This is not the most efficient implementation,
as it effectively tries to store all possible assignments.

Whilst this lets it be as flexible as possible, it:

  1. uses a lot more space
  2. has much worse time complexity

Than specialised implementations of constraints.
If you want a more performant implementation, check out others in crate::systems.

Trait Implementations§

Source§

impl<V: Hash + Eq + Clone, T: Hash + Eq + Clone> Constraint for DiscreteConstraint<V, T>

Source§

type Var = V

The type of variables assigned by the Constraint
Source§

type Solution = DiscreteAssignment<V, T>

Any solution to a Constraint
Source§

type ConflictErr = ()

The error raised when 2 constraints conflict with each other
Source§

fn size(&self) -> usize

An approximation to the number of unique assignments that self has. Read more
Source§

fn variables(&self) -> impl Iterator<Item = Self::Var>

All variables that self affects
Source§

fn decompositions(&self) -> impl Iterator<Item = Self>

Possible decompositions for this constraint. Read more
Source§

fn reduce(&mut self, other: &Self) -> Result<bool, Self::ConflictErr>

Removes the overlap between another constraint and this one.
This is useful as it lets us remove uncertainty from the system
and make it simpler to solve. Read more
Source§

fn pop_solution(&mut self) -> Option<Self::Solution>

Pops all variables that have a unique assignment in this constraint
Source§

impl<V: Debug, T: Debug + Hash + Eq> Debug for DiscreteConstraint<V, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V, T: Hash + Eq> Default for DiscreteConstraint<V, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<V: Hash + Eq + Debug, T: Hash + Eq, I: IntoIterator<Item = (V, T)>> FromIterator<I> for DiscreteConstraint<V, T>

Source§

fn from_iter<U: IntoIterator<Item = I>>(iter: U) -> Self

Creates a value from an iterator. Read more
Source§

impl<V: Hash, T: Hash + Hash + Eq> Hash for DiscreteConstraint<V, T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<V: PartialEq, T: PartialEq + Hash + Eq> PartialEq for DiscreteConstraint<V, T>

Source§

fn eq(&self, other: &DiscreteConstraint<V, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<V: Eq, T: Eq + Hash + Eq> Eq for DiscreteConstraint<V, T>

Source§

impl<V, T: Hash + Eq> StructuralPartialEq for DiscreteConstraint<V, T>

Auto Trait Implementations§

§

impl<V, T> Freeze for DiscreteConstraint<V, T>

§

impl<V, T> RefUnwindSafe for DiscreteConstraint<V, T>

§

impl<V, T> Send for DiscreteConstraint<V, T>
where V: Send, T: Send,

§

impl<V, T> Sync for DiscreteConstraint<V, T>
where V: Sync, T: Sync,

§

impl<V, T> Unpin for DiscreteConstraint<V, T>
where V: Unpin, T: Unpin,

§

impl<V, T> UnwindSafe for DiscreteConstraint<V, T>
where V: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.