[−][src]Enum ddo::Domain
A domain is a set of values (isize) that may be assigned to some variable by a decision.
Important note
Domain implements the From trait for all of the usual collections.
Therefore it is considered much better and cleaner to use .into() rather
than manually specifying the variant of this enum.
Example
// This is considered much cleaner the alternative below let clean : Domain<'_> = vec![1, 2, 4].into(); // This is more verbose and less clean. Still the two implementations // are totally equivalent. let ugly : Domain<'_> = Domain::Vector(vec![1, 2, 4]);
Technical note
This enum covers the most common collections from which a domain may be
built. These, however, should be considered transparent and only a way to
iterate over those values. The technical reason for having this enum is the
following: designing an api (trait) for the Problem that would not
constraint how one can model a problem required the ability to return some
polymorphic Domain. Ideally, this domain would have been an anonymous
iterable data structure (IntoIter). But this was not possible as traits
declaration forbid impl trait for return types. Hence, the only two
remaining options were to either return a trait object (but that would've
incurred a perf-penalty because of heap allocation), or to use a polymorphic
algebraic data type. The second option was retained as it combines both
efficiency and elegance (+ it is a fairly common approach to polymorphism
in rust and c).
Variants
When the domain consists of an owned vector (vec![])
When the domain consists of a slice (array or ref to vector)
BitSet(&'a BitSet)When the domain is a compact bitset
VarSet(&'a VarSet)When domain materialises a relation between variables (i.e. successor in a TSP), then the domain can be a varset. The possible values will be the ids of the variables present in the set.
When the domain is an exclusive range (ie. 0..10)
RangeInclusive(RangeInclusive<isize>)When the domain is an inclusive range (ie. 0..=10)
Trait Implementations
impl<'a> Clone for Domain<'a>[src]
impl<'a> From<&'a [isize]> for Domain<'a>[src]
Implements the conversion from a slice of integers to a domain
impl<'a> From<&'a BitSet> for Domain<'a>[src]
Implements the conversion from a bitset of integers to a domain
impl<'a> From<&'a VarSet> for Domain<'a>[src]
Implements the conversion from a varset to a domain
impl<'_> From<Range<isize>> for Domain<'_>[src]
Implements the conversion from a range of integers to a domain
impl<'_> From<RangeInclusive<isize>> for Domain<'_>[src]
Implements the conversion from an inclusive range of integers to a domain
pub fn from(r: RangeInclusive<isize>) -> Self[src]
impl<'_> From<Vec<isize, Global>> for Domain<'_>[src]
Implements the conversion from a vector of integers to a domain
impl<'a> IntoIterator for Domain<'a>[src]
As stated above, domains are considered only useful as a means to iterate
over the set of values that may be affected to some given variable. Thus,
Domain implements to IntoIterator trait which makes it suitable to use
in loops (and gives anyone the ability to derive an iterator for the values
of the domain).
Auto Trait Implementations
impl<'a> RefUnwindSafe for Domain<'a>
impl<'a> Send for Domain<'a>
impl<'a> Sync for Domain<'a>
impl<'a> Unpin for Domain<'a>
impl<'a> UnwindSafe for Domain<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,