Skip to main content

Builder

Struct Builder 

Source
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<(), (), ()>

Source

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>

Source

pub fn state<NewState>(self, state: NewState) -> Builder<T, NewState, Heap>

Source

pub fn heap<NewHeap>(self, heap: NewHeap) -> Builder<T, State, NewHeap>

Source

pub fn entry<Entry>(self, entry: Entry) -> Builder<Entry, State, Heap>

Source

pub fn build<Text: ?Sized>(self, text: &Text) -> Parser<'_, T>
where T: Action<Text = Text, State = State, Heap = Heap>,

Build a Parser with the given text.

Trait Implementations§

Source§

impl<T: Clone, State: Clone, Heap: Clone> Clone for Builder<T, State, Heap>

Source§

fn clone(&self) -> Builder<T, State, Heap>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy, State: Copy, Heap: Copy> Copy for Builder<T, State, Heap>

Source§

impl<T: Debug, State: Debug, Heap: Debug> Debug for Builder<T, State, Heap>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Builder<(), (), ()>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, State, Heap> Freeze for Builder<T, State, Heap>
where State: Freeze, Heap: Freeze, T: Freeze,

§

impl<T, State, Heap> RefUnwindSafe for Builder<T, State, Heap>
where State: RefUnwindSafe, Heap: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, State, Heap> Send for Builder<T, State, Heap>
where State: Send, Heap: Send, T: Send,

§

impl<T, State, Heap> Sync for Builder<T, State, Heap>
where State: Sync, Heap: Sync, T: Sync,

§

impl<T, State, Heap> Unpin for Builder<T, State, Heap>
where State: Unpin, Heap: Unpin, T: Unpin,

§

impl<T, State, Heap> UnsafeUnpin for Builder<T, State, Heap>
where State: UnsafeUnpin, Heap: UnsafeUnpin, T: UnsafeUnpin,

§

impl<T, State, Heap> UnwindSafe for Builder<T, State, Heap>
where State: UnwindSafe, Heap: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Concat<()> for T

Source§

type Output = T

The concat result.
Source§

fn concat(self, _: ()) -> <T as Concat<()>>::Output

Concat self with the rhs.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.