pub struct Builder<T, State = (), Heap = ()> { /* private fields */ }Expand description
A builder for Parser.
§Examples
§Basics
use whitehole::{parser::Parser, combinator::eat};
Parser::builder()
// Set the entry action
.entry(eat("hello ") + "world")
// Build the parser
.build("hello world");§Contextual
use whitehole::{parser::Parser, combinator::contextual};
// Generate contextual combinators
contextual!(MyState, MyHeap);
Parser::builder()
// Set the state
.state(MyState::new())
// Set the heap
.heap(MyHeap::new())
// Set the entry action
.entry(eat("hello ") + "world")
// Build the parser
.build("hello world");Implementations§
Source§impl Builder<(), (), ()>
impl Builder<(), (), ()>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Create a new instance with Parser::state and Parser::heap set to ().
Source§impl<T, State, Heap> Builder<T, State, Heap>
impl<T, State, Heap> Builder<T, State, Heap>
Sourcepub fn state<NewState>(self, state: NewState) -> Builder<T, NewState, Heap>
pub fn state<NewState>(self, state: NewState) -> Builder<T, NewState, Heap>
Set Parser::state.
Sourcepub fn heap<NewHeap>(self, heap: NewHeap) -> Builder<T, State, NewHeap>
pub fn heap<NewHeap>(self, heap: NewHeap) -> Builder<T, State, NewHeap>
Set Parser::heap.
Sourcepub fn entry<Entry>(self, entry: Entry) -> Builder<Entry, State, Heap>
pub fn entry<Entry>(self, entry: Entry) -> Builder<Entry, State, Heap>
Set Parser::entry.
Trait Implementations§
impl<T: Copy, State: Copy, Heap: Copy> Copy for Builder<T, State, Heap>
Auto Trait Implementations§
impl<T, State, Heap> Freeze for Builder<T, State, Heap>
impl<T, State, Heap> RefUnwindSafe for Builder<T, State, Heap>
impl<T, State, Heap> Send for Builder<T, State, Heap>
impl<T, State, Heap> Sync for Builder<T, State, Heap>
impl<T, State, Heap> Unpin for Builder<T, State, Heap>
impl<T, State, Heap> UnsafeUnpin for Builder<T, State, Heap>
impl<T, State, Heap> UnwindSafe for Builder<T, State, Heap>
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