Trait cfg::rule_container::RuleContainer
source · pub trait RuleContainer: Sized {
Show 13 methods
// Required methods
fn sym_source(&self) -> &SymbolSource;
fn sym_source_mut(&mut self) -> &mut SymbolSource;
fn retain<F>(&mut self, f: F)
where F: FnMut(RuleRef<'_>) -> bool;
fn add_rule(&mut self, rule_ref: RuleRef<'_>);
fn history_graph(&self) -> &HistoryGraph;
fn add_history_node(&mut self, node: HistoryNode) -> NonZero<usize>;
fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>>
where Self: 'a;
// Provided methods
fn sym<const N: usize>(&mut self) -> [Symbol; N] { ... }
fn next_sym(&mut self) -> Symbol { ... }
fn num_syms(&self) -> usize { ... }
fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self> { ... }
fn precedenced_rule(
&mut self,
lhs: Symbol,
) -> PrecedencedRuleBuilder<&mut Self> { ... }
fn reverse(&self) -> Self
where Self: Default { ... }
}
Expand description
Trait for rule and symbol containers.
Required Methods§
sourcefn sym_source(&self) -> &SymbolSource
fn sym_source(&self) -> &SymbolSource
Returns an immutable reference to the grammar’s symbol source.
sourcefn sym_source_mut(&mut self) -> &mut SymbolSource
fn sym_source_mut(&mut self) -> &mut SymbolSource
Returns a mutable reference to the grammar’s symbol source.
sourcefn retain<F>(&mut self, f: F)
fn retain<F>(&mut self, f: F)
Retains only the rules specified by the predicate.
In other words, removes all rules rule
for which f(&rule)
returns false.
sourcefn add_rule(&mut self, rule_ref: RuleRef<'_>)
fn add_rule(&mut self, rule_ref: RuleRef<'_>)
Inserts a rule with lhs
and rhs
on its LHS and RHS. The rule carries history
.
fn history_graph(&self) -> &HistoryGraph
fn add_history_node(&mut self, node: HistoryNode) -> NonZero<usize>
fn rules<'a>(&'a self) -> impl Iterator<Item = RuleRef<'a>>where
Self: 'a,
Provided Methods§
sourcefn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self>
fn rule(&mut self, lhs: Symbol) -> RuleBuilder<&mut Self>
Starts building a new rule.
sourcefn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self>
fn precedenced_rule(&mut self, lhs: Symbol) -> PrecedencedRuleBuilder<&mut Self>
Starts building a new precedenced rule.
Object Safety§
This trait is not object safe.