pub struct ChoiceNode { /* private fields */ }Expand description
Randomly renders one child node from a list of alternatives.
This is produced from text-rendered config arrays. For example,
mood = [happy, sad] becomes a choice between two literal nodes. If the
array is empty, rendering returns RenderError::EmptyChoice.
Implementations§
Source§impl ChoiceNode
impl ChoiceNode
Sourcepub fn new(nodes: Vec<Box<dyn TextGeneratorNode>>) -> Self
pub fn new(nodes: Vec<Box<dyn TextGeneratorNode>>) -> Self
Creates a choice node from renderable alternatives.
Trait Implementations§
Source§impl TextGeneratorNode for ChoiceNode
impl TextGeneratorNode for ChoiceNode
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 ChoiceNode
impl !RefUnwindSafe for ChoiceNode
impl !Send for ChoiceNode
impl !Sync for ChoiceNode
impl Unpin for ChoiceNode
impl UnsafeUnpin for ChoiceNode
impl !UnwindSafe for ChoiceNode
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