Struct peepmatic_automata::InsertionBuilder [−][src]
pub struct InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output, { /* fields omitted */ }
Expand description
A builder for a new entry in a transducer automata.
Implementations
impl<'a, TAlphabet, TState, TOutput> InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]
impl<'a, TAlphabet, TState, TOutput> InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Clone + Eq + Hash + Ord,
TState: Clone + Eq + Hash,
TOutput: Output,
[src]pub fn next(&mut self, input: TAlphabet, output: TOutput) -> &mut Self
[src]
pub fn next(&mut self, input: TAlphabet, output: TOutput) -> &mut Self
[src]Insert the next character of input for this entry, and the associated output that should be emitted along with it.
In general, you want to add all of your output on the very first next
call, and use Output::empty()
for all the
rest. This enables the most tail-sharing of suffixes, which leads to the
most compact automatas.
However, there are times when you cannot emit output yet, as it
depends on having moved throught he automata further. For example, with
peepmatic
we cannot bind something from an optimization’s left-hand
side’s pattern until after we know it exists, which only happens after
we’ve moved some distance through the automata.
pub fn finish(self)
[src]
pub fn finish(self)
[src]Finish this insertion.
Failure to call this method before this InsertionBuilder
is dropped
means that the insertion is not committed in the builder, and future
calls to InsertionBuilder::next
will
panic!
pub fn set_state_data(&mut self, data: TState) -> &mut Self
[src]
pub fn set_state_data(&mut self, data: TState) -> &mut Self
[src]Set the optional, custom data for the current state.
If you assign different state data to two otherwise-identical states within the same shared prefix during insertion, it is implementation defined which state and custom state data is kept.
For suffixes, assigning different state data to two otehrwise-identical states will result in the duplication of those states: they won’t get de-duplicated.
pub fn get_state_data(&self) -> Option<&TState>
[src]
pub fn get_state_data(&self) -> Option<&TState>
[src]Get the current state’s optional, custom data, if any.
For shared prefixes, this may return state data that was assigned to an equivalent state that was added earlier in the build process.
Trait Implementations
Auto Trait Implementations
impl<'a, TAlphabet, TState, TOutput> RefUnwindSafe for InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
TAlphabet: RefUnwindSafe,
TOutput: RefUnwindSafe,
TState: RefUnwindSafe,
impl<'a, TAlphabet, TState, TOutput> Send for InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Send,
TOutput: Send,
TState: Send,
TAlphabet: Send,
TOutput: Send,
TState: Send,
impl<'a, TAlphabet, TState, TOutput> Sync for InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TAlphabet: Sync,
TOutput: Sync,
TState: Sync,
TAlphabet: Sync,
TOutput: Sync,
TState: Sync,
impl<'a, TAlphabet, TState, TOutput> Unpin for InsertionBuilder<'a, TAlphabet, TState, TOutput> where
TOutput: Unpin,
TOutput: Unpin,