pub struct StatefulStringGenerator(_);
Expand description
This is a stateful string generator based on the tracery grammar. Note that since it is stateful, it does support variables.
Implementations§
source§impl StatefulStringGenerator
impl StatefulStringGenerator
sourcepub fn new<T: Clone + Into<String>>(
rules: &[(T, &[T])],
starting_point: Option<T>
) -> Self
pub fn new<T: Clone + Into<String>>( rules: &[(T, &[T])], starting_point: Option<T> ) -> Self
This provides a new stateful generating using tracery grammar.
You provide a set of rules as (Key, &[Values])
and optionally a starting point.
If no starting point is provided, we fall back on “origin”
sourcepub fn clone_grammar(grammar: &TraceryGrammar) -> Self
pub fn clone_grammar(grammar: &TraceryGrammar) -> Self
This creates a new stateful string generator by cloning an existing tracery grammar.
sourcepub fn from_grammar(grammar: TraceryGrammar) -> Self
pub fn from_grammar(grammar: TraceryGrammar) -> Self
This creates a stateful generator wrapping an existing grammar.
Trait Implementations§
source§impl Clone for StatefulStringGenerator
impl Clone for StatefulStringGenerator
source§fn clone(&self) -> StatefulStringGenerator
fn clone(&self) -> StatefulStringGenerator
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Component for StatefulStringGeneratorwhere
Self: Send + Sync + 'static,
impl Component for StatefulStringGeneratorwhere Self: Send + Sync + 'static,
source§impl Debug for StatefulStringGenerator
impl Debug for StatefulStringGenerator
source§impl StatefulGenerator<String, String, String, TraceryGrammar> for StatefulStringGenerator
impl StatefulGenerator<String, String, String, TraceryGrammar> for StatefulStringGenerator
source§fn generate<R: GrammarRandomNumberGenerator>(
&mut self,
rng: &mut R
) -> Option<String>
fn generate<R: GrammarRandomNumberGenerator>( &mut self, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from the grammar’s default rulesource§fn generate_at<R: GrammarRandomNumberGenerator>(
&mut self,
key: &String,
rng: &mut R
) -> Option<String>
fn generate_at<R: GrammarRandomNumberGenerator>( &mut self, key: &String, rng: &mut R ) -> Option<String>
This function generates a new value of
StreamType
, starting from a provided rule keysource§fn expand_from<R: GrammarRandomNumberGenerator>(
&mut self,
initial: &String,
rng: &mut R
) -> String
fn expand_from<R: GrammarRandomNumberGenerator>( &mut self, initial: &String, rng: &mut R ) -> String
This function generates a new value of
StreamType
, starting by processing an initial input of StreamType
source§fn set_grammar(&mut self, grammar: &TraceryGrammar)
fn set_grammar(&mut self, grammar: &TraceryGrammar)
This sets the used grammar
source§fn get_grammar(&self) -> &TraceryGrammar
fn get_grammar(&self) -> &TraceryGrammar
This gets an immutable reference to the grammar
source§fn get_grammar_mut(&mut self) -> &mut TraceryGrammar
fn get_grammar_mut(&mut self) -> &mut TraceryGrammar
This gets a mutable reference to the grammar
impl Resource for StatefulStringGeneratorwhere Self: Send + Sync + 'static,
Auto Trait Implementations§
impl RefUnwindSafe for StatefulStringGenerator
impl Send for StatefulStringGenerator
impl Sync for StatefulStringGenerator
impl Unpin for StatefulStringGenerator
impl UnwindSafe for StatefulStringGenerator
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
§impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a, Aligned>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.