pub struct Assignment { /* private fields */ }Expand description
Variable → value binding for density / outcome lookup.
Implementations§
Source§impl Assignment
impl Assignment
Sourcepub fn from_pairs(pairs: impl IntoIterator<Item = (VariableId, Value)>) -> Self
pub fn from_pairs(pairs: impl IntoIterator<Item = (VariableId, Value)>) -> Self
Build from unsorted pairs (sorted + last-wins on duplicate vars).
Sourcepub fn set(&mut self, var: VariableId, value: Value)
pub fn set(&mut self, var: VariableId, value: Value)
Insert or replace a binding.
Sourcepub fn get(&self, var: VariableId) -> Option<&Value>
pub fn get(&self, var: VariableId) -> Option<&Value>
Borrow value for var, if present.
Sourcepub fn entries(&self) -> &[(VariableId, Value)]
pub fn entries(&self) -> &[(VariableId, Value)]
All bindings, sorted.
Sourcepub fn extend_from(&mut self, other: &Assignment)
pub fn extend_from(&mut self, other: &Assignment)
Extend with another assignment (other wins on conflict).
Sourcepub fn remove(&mut self, var: VariableId) -> Option<Value>
pub fn remove(&mut self, var: VariableId) -> Option<Value>
Remove the binding for var, returning the previous value (if any).
Lets evaluators treat one shared assignment as a binding stack: scoped
bindings are set on entry and removed (or restored) on exit instead
of cloning the whole assignment per scope.
Sourcepub fn values_for(&self, vars: &[VariableId]) -> Result<Vec<Value>, EvalError>
pub fn values_for(&self, vars: &[VariableId]) -> Result<Vec<Value>, EvalError>
Restrict to the given variables (order of vars preserved in returned values).
Trait Implementations§
Source§impl Clone for Assignment
impl Clone for Assignment
Source§fn clone(&self) -> Assignment
fn clone(&self) -> Assignment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Assignment
impl Debug for Assignment
Source§impl Default for Assignment
impl Default for Assignment
Source§fn default() -> Assignment
fn default() -> Assignment
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for Assignment
impl RefUnwindSafe for Assignment
impl Send for Assignment
impl Sync for Assignment
impl Unpin for Assignment
impl UnsafeUnpin for Assignment
impl UnwindSafe for Assignment
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
Mutably borrows from an owned value. Read more