Skip to main content

Dist

Struct Dist 

Source
pub struct Dist {
    pub subject_ty: Ty,
    pub plain_var: Option<VarId>,
    pub vars: Vec<VarId>,
    pub items: Vec<Item>,
    pub default: Option<DefaultWeight>,
    pub subject: Option<Expr>,
}
Expand description

One dist expression.

Fields§

§subject_ty: Ty

The type of the distributed expression.

§plain_var: Option<VarId>

The distributed variable, when the expression is exactly one random variable (the case the weighting is exact for).

§vars: Vec<VarId>

Every random variable the distributed expression reads, ascending.

§items: Vec<Item>

The explicit items, in source order; code i is item i.

§default: Option<DefaultWeight>

The default item; its code follows the explicit items’.

§subject: Option<Expr>

Some(subject) marks a template: a dist written inside a foreach over a dynamic array or queue (LRM 18.5.7.1, 18.5.3), which must hold once per element. Its expressions are array-level IR over the loop variable and cannot be weighed as they stand: array::expand makes one instance of the dist, with a selector of its own, per iteration (module docs of super::array), expanding subject (the array-level distributed expression), the bounds and the weights for that iteration. A template keeps its selector slot in the program but is never planned itself.

Implementations§

Source§

impl Dist

Source

pub fn validate(&self) -> Result<(), IrError>

Checks every expression of the dist against the IR’s typing rules and that the weights and bounds read no random variable.

Source

pub fn codes(&self) -> usize

The number of selector codes: one per item, plus the default’s.

Source

pub fn selector_ty(&self) -> Ty

The selector variable’s type: just wide enough for Self::codes.

Source

pub fn conjunct(&self, sel: VarId) -> Expr

The conjunct OR_i (sel == i && member_i) (the default’s member is “no explicit item holds”).

Source

pub fn weights( &self, states: &[Option<BigUint>], ) -> Result<Vec<Weight>, DistError>

The per-value weight of every selector code under the current values of the state variables: item i’s weight (:=) or its weight divided by the number of values of the item (:/), and likewise for the default over the values no explicit item names. A weight of an empty item is 0.

Trait Implementations§

Source§

impl Clone for Dist

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Dist

Source§

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

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

impl<'de> Deserialize<'de> for Dist

Source§

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

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

impl Eq for Dist

Source§

impl PartialEq for Dist

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Dist

Source§

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

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

impl StructuralPartialEq for Dist

Auto Trait Implementations§

§

impl Freeze for Dist

§

impl RefUnwindSafe for Dist

§

impl Send for Dist

§

impl Sync for Dist

§

impl Unpin for Dist

§

impl UnsafeUnpin for Dist

§

impl UnwindSafe for Dist

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

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

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

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

Source§

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.

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

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

Source§

fn vzip(self) -> V