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: TyThe 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
impl Dist
Sourcepub fn validate(&self) -> Result<(), IrError>
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.
Sourcepub fn selector_ty(&self) -> Ty
pub fn selector_ty(&self) -> Ty
The selector variable’s type: just wide enough for Self::codes.
Sourcepub fn conjunct(&self, sel: VarId) -> Expr
pub fn conjunct(&self, sel: VarId) -> Expr
The conjunct OR_i (sel == i && member_i) (the default’s member is
“no explicit item holds”).
Sourcepub fn weights(
&self,
states: &[Option<BigUint>],
) -> Result<Vec<Weight>, DistError>
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<'de> Deserialize<'de> for Dist
impl<'de> Deserialize<'de> for Dist
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>,
impl Eq for Dist
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.