pub enum GroundDomain {
Empty(ReturnType),
Bool,
Int(Vec<Range<i32>>),
Set(SetAttr<i32>, Moo<GroundDomain>),
Matrix(Moo<GroundDomain>, Vec<Moo<GroundDomain>>),
Tuple(Vec<Moo<GroundDomain>>),
Record(Vec<RecordEntryGround>),
Function(FuncAttr, Moo<GroundDomain>, Moo<GroundDomain>),
}Variants§
Empty(ReturnType)
An empty domain of a given type
Bool
A boolean value (true / false)
Int(Vec<Range<i32>>)
An integer value in the given ranges (e.g. int(1, 3..5))
Set(SetAttr<i32>, Moo<GroundDomain>)
A set of elements drawn from the inner domain
Matrix(Moo<GroundDomain>, Vec<Moo<GroundDomain>>)
An N-dimensional matrix of elements drawn from the inner domain, and indices from the n index domains
Tuple(Vec<Moo<GroundDomain>>)
A tuple of N elements, each with its own domain
Record(Vec<RecordEntryGround>)
A record
Function(FuncAttr, Moo<GroundDomain>, Moo<GroundDomain>)
A function with a domain and range
Implementations§
Source§impl GroundDomain
impl GroundDomain
pub fn union(&self, other: &GroundDomain) -> Result<GroundDomain, DomainOpError>
Sourcepub fn intersect(
&self,
other: &GroundDomain,
) -> Result<GroundDomain, DomainOpError>
pub fn intersect( &self, other: &GroundDomain, ) -> Result<GroundDomain, DomainOpError>
Calculates the intersection of two domains.
§Errors
DomainOpError::Unboundedif either of the input domains are unbounded.DomainOpError::WrongTypeif the input domains are different types, or are not integer or set domains.
pub fn values(&self) -> Result<Box<dyn Iterator<Item = Literal>>, DomainOpError>
Sourcepub fn length(&self) -> Result<u64, DomainOpError>
pub fn length(&self) -> Result<u64, DomainOpError>
Gets the length of this domain.
§Errors
DomainOpError::Unboundedif the input domain is of infinite size.
pub fn contains(&self, lit: &Literal) -> Result<bool, DomainOpError>
Sourcepub fn values_i32(&self) -> Result<Vec<i32>, DomainOpError>
pub fn values_i32(&self) -> Result<Vec<i32>, DomainOpError>
Returns a list of all possible values in an integer domain.
§Errors
DomainOpError::NotIntegerif the domain is not an integer domain.DomainOpError::Unboundedif the domain is unbounded.
Sourcepub fn from_set_i32(elements: &BTreeSet<i32>) -> GroundDomain
pub fn from_set_i32(elements: &BTreeSet<i32>) -> GroundDomain
Creates an [Domain::Int] containing the given integers.
§Examples
use conjure_cp_core::ast::{GroundDomain, Range};
use conjure_cp_core::{domain_int_ground,range};
use std::collections::BTreeSet;
let elements = BTreeSet::from([1,2,3,4,5]);
let domain = GroundDomain::from_set_i32(&elements);
assert_eq!(domain,domain_int_ground!(1..5));use conjure_cp_core::ast::{GroundDomain,Range};
use conjure_cp_core::{domain_int_ground,range};
use std::collections::BTreeSet;
let elements = BTreeSet::from([1,2,4,5,7,8,9,10]);
let domain = GroundDomain::from_set_i32(&elements);
assert_eq!(domain,domain_int_ground!(1..2,4..5,7..10));use conjure_cp_core::ast::{GroundDomain,Range,ReturnType};
use std::collections::BTreeSet;
let elements = BTreeSet::from([]);
let domain = GroundDomain::from_set_i32(&elements);
assert!(matches!(domain,GroundDomain::Empty(ReturnType::Int)))Sourcepub fn apply_i32(
&self,
op: fn(i32, i32) -> Option<i32>,
other: &GroundDomain,
) -> Result<GroundDomain, DomainOpError>
pub fn apply_i32( &self, op: fn(i32, i32) -> Option<i32>, other: &GroundDomain, ) -> Result<GroundDomain, DomainOpError>
Returns the domain that is the result of applying a binary operation to two integer domains.
The given operator may return None if the operation is not defined for its arguments.
Undefined values will not be included in the resulting domain.
§Errors
DomainOpError::Unboundedif either of the input domains are unbounded.DomainOpError::NotIntegerif either of the input domains are not integers.
Sourcepub fn from_literal_vec(
literals: &[Literal],
) -> Result<GroundDomain, DomainOpError>
pub fn from_literal_vec( literals: &[Literal], ) -> Result<GroundDomain, DomainOpError>
For a vector of literals, creates a domain that contains all the elements.
The literals must all be of the same type.
For abstract literals, this method merges the element domains of the literals, but not the index domains. Thus, for fixed-sized abstract literals (matrices, tuples, records, etc.), all literals in the vector must also have the same size / index domain:
- Matrices: all literals must have the same index domain.
- Tuples: all literals must have the same number of elements.
- Records: all literals must have the same fields.
§Errors
- DomainOpError::WrongType if the input literals are of a different type to each-other, as described above.
§Examples
use conjure_cp_core::ast::{Range, Literal, ReturnType, GroundDomain};
let domain = GroundDomain::from_literal_vec(&vec![]);
assert_eq!(domain,Ok(GroundDomain::Empty(ReturnType::Unknown)));use conjure_cp_core::ast::{GroundDomain,Range,Literal, AbstractLiteral};
use conjure_cp_core::{domain_int_ground, range, matrix};
// `[1,2;int(2..3)], [4,5; int(2..3)]` has domain
// `matrix indexed by [int(2..3)] of int(1..2,4..5)`
let matrix_1 = Literal::AbstractLiteral(matrix![Literal::Int(1),Literal::Int(2);domain_int_ground!(2..3)]);
let matrix_2 = Literal::AbstractLiteral(matrix![Literal::Int(4),Literal::Int(5);domain_int_ground!(2..3)]);
let domain = GroundDomain::from_literal_vec(&vec![matrix_1,matrix_2]);
let expected_domain = Ok(GroundDomain::Matrix(
domain_int_ground!(1..2,4..5),vec![domain_int_ground!(2..3)]));
assert_eq!(domain,expected_domain);use conjure_cp_core::ast::{GroundDomain,Range,Literal, AbstractLiteral,DomainOpError};
use conjure_cp_core::{domain_int_ground, range, matrix};
// `[1,2;int(2..3)], [4,5; int(1..2)]` cannot be combined
// `matrix indexed by [int(2..3)] of int(1..2,4..5)`
let matrix_1 = Literal::AbstractLiteral(matrix![Literal::Int(1),Literal::Int(2);domain_int_ground!(2..3)]);
let matrix_2 = Literal::AbstractLiteral(matrix![Literal::Int(4),Literal::Int(5);domain_int_ground!(1..2)]);
let domain = GroundDomain::from_literal_vec(&vec![matrix_1,matrix_2]);
assert_eq!(domain,Err(DomainOpError::WrongType));use conjure_cp_core::ast::{GroundDomain,Range,Literal, AbstractLiteral};
use conjure_cp_core::{domain_int_ground,range, matrix};
// `[[1,2; int(1..2)];int(2)], [[4,5; int(1..2)]; int(2)]` has domain
// `matrix indexed by [int(2),int(1..2)] of int(1..2,4..5)`
let matrix_1 = Literal::AbstractLiteral(matrix![Literal::AbstractLiteral(matrix![Literal::Int(1),Literal::Int(2);domain_int_ground!(1..2)]); domain_int_ground!(2)]);
let matrix_2 = Literal::AbstractLiteral(matrix![Literal::AbstractLiteral(matrix![Literal::Int(4),Literal::Int(5);domain_int_ground!(1..2)]); domain_int_ground!(2)]);
let domain = GroundDomain::from_literal_vec(&vec![matrix_1,matrix_2]);
let expected_domain = Ok(GroundDomain::Matrix(
domain_int_ground!(1..2,4..5),
vec![domain_int_ground!(2),domain_int_ground!(1..2)]));
assert_eq!(domain,expected_domain);Trait Implementations§
Source§impl Biplate<GroundDomain> for Domain
impl Biplate<GroundDomain> for Domain
Source§fn biplate(
&self,
) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> Domain>)
fn biplate( &self, ) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> Domain>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl Biplate<GroundDomain> for GroundDomain
impl Biplate<GroundDomain> for GroundDomain
Source§fn biplate(
&self,
) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> GroundDomain>)
fn biplate( &self, ) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> GroundDomain>)
§fn with_children_bi(&self, children: VecDeque<To>) -> Self
fn with_children_bi(&self, children: VecDeque<To>) -> Self
§fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
fn descend_bi(&self, op: &impl Fn(To) -> To) -> Self
Uniplate::descend] Read more§fn universe_bi(&self) -> VecDeque<To>
fn universe_bi(&self) -> VecDeque<To>
§fn children_bi(&self) -> VecDeque<To>
fn children_bi(&self) -> VecDeque<To>
§fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
fn transform_bi(&self, op: &impl Fn(To) -> To) -> Self
§fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn holes_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
§fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
fn contexts_bi(&self) -> impl Iterator<Item = (To, impl Fn(To))>
Source§impl Clone for GroundDomain
impl Clone for GroundDomain
Source§fn clone(&self) -> GroundDomain
fn clone(&self) -> GroundDomain
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GroundDomain
impl Debug for GroundDomain
Source§impl<'de> Deserialize<'de> for GroundDomain
impl<'de> Deserialize<'de> for GroundDomain
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for GroundDomain
impl Display for GroundDomain
Source§impl From<GroundDomain> for DomainPtr
impl From<GroundDomain> for DomainPtr
Source§fn from(value: GroundDomain) -> Self
fn from(value: GroundDomain) -> Self
Source§impl Hash for GroundDomain
impl Hash for GroundDomain
Source§impl PartialEq for GroundDomain
impl PartialEq for GroundDomain
Source§impl Quine for GroundDomain
impl Quine for GroundDomain
fn ctor_tokens(&self) -> TokenStream
Source§impl Serialize for GroundDomain
impl Serialize for GroundDomain
Source§impl Typeable for GroundDomain
impl Typeable for GroundDomain
fn return_type(&self) -> ReturnType
Source§impl Uniplate for GroundDomain
impl Uniplate for GroundDomain
Source§fn uniplate(
&self,
) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> GroundDomain>)
fn uniplate( &self, ) -> (Tree<GroundDomain>, Box<dyn Fn(Tree<GroundDomain>) -> GroundDomain>)
Uniplate. Read more§fn descend(&self, op: &impl Fn(Self) -> Self) -> Self
fn descend(&self, op: &impl Fn(Self) -> Self) -> Self
§fn universe(&self) -> VecDeque<Self>
fn universe(&self) -> VecDeque<Self>
§fn with_children(&self, children: VecDeque<Self>) -> Self
fn with_children(&self, children: VecDeque<Self>) -> Self
§fn transform(&self, f: &impl Fn(Self) -> Self) -> Self
fn transform(&self, f: &impl Fn(Self) -> Self) -> Self
§fn rewrite(&self, f: &impl Fn(Self) -> Option<Self>) -> Self
fn rewrite(&self, f: &impl Fn(Self) -> Option<Self>) -> Self
§fn cata<T>(&self, op: &impl Fn(Self, VecDeque<T>) -> T) -> T
fn cata<T>(&self, op: &impl Fn(Self, VecDeque<T>) -> T) -> T
impl Eq for GroundDomain
impl StructuralPartialEq for GroundDomain
Auto Trait Implementations§
impl Freeze for GroundDomain
impl RefUnwindSafe for GroundDomain
impl Send for GroundDomain
impl Sync for GroundDomain
impl Unpin for GroundDomain
impl UnwindSafe for GroundDomain
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes
Size for each variant:
Empty: 36 bytesBool: 0 bytesInt: 28 bytesSet: 20 bytesMatrix: 36 bytesTuple: 28 bytesRecord: 28 bytesFunction: 36 bytes