pub struct RuleArena<'a> { /* private fields */ }Expand description
Allocation arena for grammar rules.
Provides an easy way to allocate Rule instances while building a grammar. All of the rules
owned by the arena will be dropped when the arena itself is dropped.
Implementations§
Source§impl<'a> RuleArena<'a>
impl<'a> RuleArena<'a>
Sourcepub fn alloc(&self, rule: Rule<'a>) -> &Rule<'a>
pub fn alloc(&self, rule: Rule<'a>) -> &Rule<'a>
Take ownership of a constructed rule and keep it until the arena is destroyed.
Sourcepub fn text<T: Into<Cow<'a, str>>>(&self, text: T) -> &Rule<'a>
pub fn text<T: Into<Cow<'a, str>>>(&self, text: T) -> &Rule<'a>
Allocate a rule that defines a sequence of words to be recognized.
Sourcepub fn choice<L: Into<Cow<'a, [&'a Rule<'a>]>>>(&self, options: L) -> &Rule<'a>
pub fn choice<L: Into<Cow<'a, [&'a Rule<'a>]>>>(&self, options: L) -> &Rule<'a>
Allocate a rule that defines a set of alternatives to choose from.
Sourcepub fn sequence<L: Into<Cow<'a, [&'a Rule<'a>]>>>(&self, parts: L) -> &Rule<'a>
pub fn sequence<L: Into<Cow<'a, [&'a Rule<'a>]>>>(&self, parts: L) -> &Rule<'a>
Allocate a rule the defines a sequence of sub-rules that must be recognized in order.
Auto Trait Implementations§
impl<'a> !Freeze for RuleArena<'a>
impl<'a> !RefUnwindSafe for RuleArena<'a>
impl<'a> Send for RuleArena<'a>
impl<'a> !Sync for RuleArena<'a>
impl<'a> Unpin for RuleArena<'a>
impl<'a> UnwindSafe for RuleArena<'a>
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