pub trait Domain:
Clone
+ PartialEq
+ Debug {
type Value: Clone + PartialEq + Debug;
// Required methods
fn size(&self) -> usize;
fn contains(&self, val: &Self::Value) -> bool;
fn remove(&mut self, val: &Self::Value) -> bool;
fn add(&mut self, val: &Self::Value);
fn values(&self) -> Vec<Self::Value>;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn is_singleton(&self) -> bool { ... }
fn singleton_value(&self) -> Option<Self::Value> { ... }
fn iter(&self) -> impl Iterator<Item = Self::Value> { ... }
}Expand description
A domain of possible values for a CSP variable.
The iteration primitive is iter(), not values(). Implementations should
provide zero-allocation iterators where possible (e.g. BitsetDomain iterates
bits from a u128 without heap allocation).
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn is_singleton(&self) -> bool
fn is_singleton(&self) -> bool
Whether the domain contains exactly one value.
Sourcefn singleton_value(&self) -> Option<Self::Value>
fn singleton_value(&self) -> Option<Self::Value>
If the domain is a singleton, return its sole value.
Sourcefn iter(&self) -> impl Iterator<Item = Self::Value>
fn iter(&self) -> impl Iterator<Item = Self::Value>
Iterate over current values without allocating.
Default delegates to values().into_iter(). Override for zero-alloc
iteration (e.g. BitsetDomain yields bits from a u128 copy).
The returned iterator is owned — it does NOT borrow &self, so the
domain can be mutated while iteration is in progress (the iterator
holds a snapshot).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".