Enum Domain

Source
pub enum Domain {
    Bool,
    Int(Vec<Range<i32>>),
    Empty(ReturnType),
    Reference(Name),
    Set(SetAttr, Box<Domain>),
    Matrix(Box<Domain>, Vec<Domain>),
    Tuple(Vec<Domain>),
    Record(Vec<RecordEntry>),
}

Variants§

§

Bool

§

Int(Vec<Range<i32>>)

An integer domain.

  • If multiple ranges are inside the domain, the values in the domain are the union of these ranges.

  • If no ranges are given, the int domain is considered unconstrained, and can take any integer value.

§

Empty(ReturnType)

An empty domain of the given type.

§

Reference(Name)

§

Set(SetAttr, Box<Domain>)

§

Matrix(Box<Domain>, Vec<Domain>)

A n-dimensional matrix with a value domain and n-index domains

§

Tuple(Vec<Domain>)

§

Record(Vec<RecordEntry>)

Implementations§

Source§

impl Domain

Source

pub fn contains(&self, lit: &Literal) -> Result<bool, DomainOpError>

Returns true if lit is a member of the domain.

§Errors
Source

pub fn values_i32(&self) -> Result<Vec<i32>, DomainOpError>

Returns a list of all possible values in the domain.

§Errors
Source

pub fn from_slice_i32(elements: &[i32]) -> Domain

Creates an Domain::Int containing the given integers.

Domain::from_set_i32 should be used instead where possible, as it is cheaper (it does not need to sort its input).

§Examples
use conjure_core::ast::{Domain,Range};

let elements = vec![1,2,3,4,5];

let domain = Domain::from_slice_i32(&elements);

let Domain::Int(ranges) = domain else {
    panic!("domain returned from from_slice_i32 should be a Domain::Int");
};

assert_eq!(ranges,vec![Range::Bounded(1,5)]);
use conjure_core::ast::{Domain,Range};

let elements = vec![1,2,4,5,7,8,9,10];

let domain = Domain::from_slice_i32(&elements);

let Domain::Int(ranges) = domain else {
    panic!("domain returned from from_slice_i32 should be a Domain::Int");
};

assert_eq!(ranges,vec![Range::Bounded(1,2),Range::Bounded(4,5),Range::Bounded(7,10)]);
use conjure_core::ast::{Domain,Range,ReturnType};

let elements = vec![];

let domain = Domain::from_slice_i32(&elements);

assert!(matches!(domain,Domain::Empty(ReturnType::Int)))
Source

pub fn from_set_i32(elements: &BTreeSet<i32>) -> Domain

Creates an Domain::Int containing the given integers.

§Examples
use conjure_core::ast::{Domain,Range};
use std::collections::BTreeSet;

let elements = BTreeSet::from([1,2,3,4,5]);

let domain = Domain::from_set_i32(&elements);

let Domain::Int(ranges) = domain else {
    panic!("domain returned from from_slice_i32 should be a Domain::Int");
};

assert_eq!(ranges,vec![Range::Bounded(1,5)]);
use conjure_core::ast::{Domain,Range};
use std::collections::BTreeSet;

let elements = BTreeSet::from([1,2,4,5,7,8,9,10]);

let domain = Domain::from_set_i32(&elements);

let Domain::Int(ranges) = domain else {
    panic!("domain returned from from_set_i32 should be a Domain::Int");
};

assert_eq!(ranges,vec![Range::Bounded(1,2),Range::Bounded(4,5),Range::Bounded(7,10)]);
use conjure_core::ast::{Domain,Range,ReturnType};
use std::collections::BTreeSet;

let elements = BTreeSet::from([]);

let domain = Domain::from_set_i32(&elements);

assert!(matches!(domain,Domain::Empty(ReturnType::Int)))
Source

pub fn values(&self) -> Result<Vec<Literal>, DomainOpError>

Gets all the Literal values inside this domain.

§Errors
Source

pub fn length(&self) -> Result<usize, DomainOpError>

Gets the length of this domain.

§Errors
Source

pub fn apply_i32( &self, op: fn(i32, i32) -> Option<i32>, other: &Domain, ) -> Result<Domain, 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
Source

pub fn is_finite(&self) -> Result<bool, DomainOpError>

Returns true if the domain is finite.

§Errors
Source

pub fn resolve(self, symbols: &SymbolTable) -> Domain

Resolves this domain to a ground domain, using the symbol table provided to resolve references.

A domain is ground iff it is not a domain reference, nor contains any domain references.

See also: SymbolTable::resolve_domain.

§Panics
  • If a reference domain in self does not exist in the given symbol table.
Source

pub fn intersect(&self, other: &Domain) -> Result<Domain, DomainOpError>

Calculates the intersection of two domains.

§Errors
Source

pub fn union(&self, other: &Domain) -> Result<Domain, DomainOpError>

Calculates the union of two domains.

§Errors

Trait Implementations§

Source§

impl Biplate<Domain> for Domain

Source§

fn biplate(&self) -> (Tree<Domain>, Box<dyn Fn(Tree<Domain>) -> Domain>)

Definition of a Biplate. Read more
§

fn with_children_bi(&self, children: VecDeque<To>) -> Self

Reconstructs the node with the given children. Read more
§

fn descend_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self

Biplate variant of [Uniplate::descend] Read more
§

fn universe_bi(&self) -> VecDeque<To>

Gets all children of a node, including itself and all children. Read more
§

fn children_bi(&self) -> VecDeque<To>

Returns the children of a type. If to == from then it returns the original element (in contrast to children). Read more
§

fn transform_bi(&self, op: Arc<dyn Fn(To) -> To>) -> Self

Applies the given function to all nodes bottom up. Read more
§

fn holes_bi(&self) -> impl Iterator<Item = (To, Arc<dyn Fn(To) -> Self>)>

Returns an iterator over all direct children of the input, paired with a function that “fills the hole” where the child was with a new value. Read more
§

fn contexts_bi(&self) -> impl Iterator<Item = (To, Arc<dyn Fn(To) -> Self>)>

Returns an iterator over the universe of the input, paired with a function that “fills the hole” where the child was with a new value. Read more
Source§

impl Clone for Domain

Source§

fn clone(&self) -> Domain

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Domain

Source§

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

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

impl<'de> Deserialize<'de> for Domain

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Domain, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Domain

Source§

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

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

impl Hash for Domain

Source§

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

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 PartialEq for Domain

Source§

fn eq(&self, other: &Domain) -> bool

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

const 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 Serialize for Domain

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Typeable for Domain

Source§

impl Uniplate for Domain

Source§

fn uniplate(&self) -> (Tree<Domain>, Box<dyn Fn(Tree<Domain>) -> Domain>)

Definition of a Uniplate. Read more
§

fn descend(&self, op: Arc<dyn Fn(Self) -> Self>) -> Self

Applies a function to all direct children of this Read more
§

fn universe(&self) -> VecDeque<Self>

Gets all children of a node, including itself and all children. Read more
§

fn children(&self) -> VecDeque<Self>

Gets the direct children (maximal substructures) of a node.
§

fn with_children(&self, children: VecDeque<Self>) -> Self

Reconstructs the node with the given children. Read more
§

fn transform(&self, f: Arc<dyn Fn(Self) -> Self>) -> Self

Applies the given function to all nodes bottom up.
§

fn rewrite(&self, f: Arc<dyn Fn(Self) -> Option<Self>>) -> Self

Rewrites by applying a rule everywhere it can.
§

fn cata<T>(&self, op: Arc<dyn Fn(Self, VecDeque<T>) -> T>) -> T

Performs a fold-like computation on each value. Read more
§

fn holes(&self) -> impl Iterator<Item = (Self, Arc<dyn Fn(Self) -> Self>)>

Returns an iterator over all direct children of the input, paired with a function that “fills the hole” where the child was with a new value.
§

fn contexts(&self) -> impl Iterator<Item = (Self, Arc<dyn Fn(Self) -> Self>)>

Returns an iterator over the universe of the input, paired with a function that “fills the hole” where the child was with a new value. Read more
Source§

impl Eq for Domain

Source§

impl StructuralPartialEq for Domain

Auto Trait Implementations§

§

impl Freeze for Domain

§

impl RefUnwindSafe for Domain

§

impl Send for Domain

§

impl Sync for Domain

§

impl Unpin for Domain

§

impl UnwindSafe for Domain

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where 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:

  • Bool: 0 bytes
  • Int: 28 bytes
  • Empty: 20 bytes
  • Reference: 36 bytes
  • Set: 20 bytes
  • Matrix: 36 bytes
  • Tuple: 28 bytes
  • Record: 28 bytes