pub struct Choicemap { /* private fields */ }
Expand description
A struct to hold all of the random choices made during the execution of a generative model.
Implementations§
Source§impl Choicemap
impl Choicemap
Sourcepub fn new() -> Choicemap
pub fn new() -> Choicemap
Create a new, blank choice map.
§Example
use r_gen::trace::Choicemap;
use r_gen::distributions::Value;
let mut choicemap = Choicemap::new();
choicemap.add_choice("p", Value::Real(0.5));
Sourcepub fn from(choices: Vec<(&str, Value)>) -> Choicemap
pub fn from(choices: Vec<(&str, Value)>) -> Choicemap
Create a new choicemap with given choices in it.
§Example
use r_gen::trace::Choicemap;
use r_gen::distributions::Value;
let mut choicemap = Choicemap::from(vec![("p", Value::Real(0.5))]);
Sourcepub fn add_choice(&mut self, identifier: &str, value: Value)
pub fn add_choice(&mut self, identifier: &str, value: Value)
Add a choice to this choicemap.
§Example
use r_gen::trace::Choicemap;
use r_gen::distributions::Value;
let mut choicemap = Choicemap::new();
choicemap.add_choice("p", Value::Real(0.5));
Sourcepub fn get_choices(&self) -> Vec<(&str, Value)>
pub fn get_choices(&self) -> Vec<(&str, Value)>
Get a list of the choices that were made in the generative model.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check whether or not the given key is already in the choicemap.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Choicemap
impl RefUnwindSafe for Choicemap
impl Send for Choicemap
impl Sync for Choicemap
impl Unpin for Choicemap
impl UnwindSafe for Choicemap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.