pub struct WeightedChoiceNode { /* private fields */ }Expand description
Randomly renders one child node using per-child weights.
Weighted choices are produced from arrays containing at least one weighted
object entry, such as { value = "common", weight = 9 }. Plain entries in
the same array receive weight 1.0.
Implementations§
Source§impl WeightedChoiceNode
impl WeightedChoiceNode
Sourcepub fn new(
entries: Vec<(Box<dyn TextGeneratorNode>, f64)>,
) -> Result<Self, RenderError>
pub fn new( entries: Vec<(Box<dyn TextGeneratorNode>, f64)>, ) -> Result<Self, RenderError>
Creates a weighted choice node from renderable alternatives and weights.
Trait Implementations§
Source§impl TextGeneratorNode for WeightedChoiceNode
impl TextGeneratorNode for WeightedChoiceNode
Source§fn generate_text(
&self,
state: &mut RenderState<'_>,
) -> Result<String, RenderError>
fn generate_text( &self, state: &mut RenderState<'_>, ) -> Result<String, RenderError>
Generates text using the supplied render state.
Auto Trait Implementations§
impl Freeze for WeightedChoiceNode
impl !RefUnwindSafe for WeightedChoiceNode
impl !Send for WeightedChoiceNode
impl !Sync for WeightedChoiceNode
impl Unpin for WeightedChoiceNode
impl UnsafeUnpin for WeightedChoiceNode
impl !UnwindSafe for WeightedChoiceNode
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