Struct FromFn

Source
pub struct FromFn<F>(/* private fields */);
Expand description

A parser returned by from_fn.

Trait Implementations§

Source§

impl<F: Clone> Clone for FromFn<F>

Source§

fn clone(&self) -> FromFn<F>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<I, S, O, F: FnOnce(I, &mut S) -> Option<(O, I)>> Parser<I, S> for FromFn<F>

Source§

type O = O

Output of the parser.
Source§

fn parse(self, input: I, state: &mut S) -> Option<(Self::O, I)>

Parse a value of type Self::O.

Auto Trait Implementations§

§

impl<F> Freeze for FromFn<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for FromFn<F>
where F: RefUnwindSafe,

§

impl<F> Send for FromFn<F>
where F: Send,

§

impl<F> Sync for FromFn<F>
where F: Sync,

§

impl<F> Unpin for FromFn<F>
where F: Unpin,

§

impl<F> UnwindSafe for FromFn<F>
where F: 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<I, S, T> Combinator<I, S> for T
where T: Parser<I, S>,

Source§

fn then<P: Parser<I, S>>(self, other: P) -> All<(Self, P)>

If both parsers yield an output, return the pair of their outputs. Read more
Source§

fn or<P: Parser<I, S>>(self, other: P) -> Any<(Self, P)>
where I: Clone,

If the first parser succeeds, return its output, otherwise return the output of the second parser. Read more
Source§

fn map<O, F: FnOnce(Self::O) -> O>(self, f: F) -> Map<Self, F>

Apply a function to the output of the parser.
Source§

fn map_with<O, F: FnOnce(Self::O, &mut S) -> O>(self, f: F) -> MapWith<Self, F>

Apply a function to the output of the parser as well as the mutable state.
Source§

fn filter<F: FnOnce(&Self::O) -> bool>(self, f: F) -> Filter<Self, F>

Succeed only if the given function yields true for the parser output.
Source§

fn filter_map<O, F: FnOnce(Self::O) -> Option<O>>( self, f: F, ) -> FilterMap<Self, F>

If the given function yields Some(y) for the parser output, succeed with y, else fail.
Source§

fn then_ignore<P: Parser<I, S>>( self, other: P, ) -> Map<All<(Self, P)>, fn((<Self as Parser<I, S>>::O, <P as Parser<I, S>>::O)) -> Self::O>

Run two parsers in sequence and discard result of second one.
Source§

fn ignore_then<P: Parser<I, S>>( self, other: P, ) -> Map<All<(Self, P)>, fn((<Self as Parser<I, S>>::O, <P as Parser<I, S>>::O)) -> P::O>

Run two parsers in sequence and discard result of first one.
Source§

fn delimited_by<L, R>( self, l: L, r: R, ) -> Map<All<(L, Self, R)>, fn((L::O, Self::O, R::O)) -> Self::O>
where L: Parser<I, S>, R: Parser<I, S>,

Run parsers l, self, and r in sequence and return only the output of self.
Source§

fn repeated<O>(self) -> Repeated<Self, fn() -> O>
where I: Clone, Self: Clone, O: Default + Extend<Self::O>,

Apply the given parser as often as possible. Read more
Source§

fn separated_by<Sep, O>(self, sep: Sep) -> SeparatedBy<Self, Sep, fn() -> O>
where I: Clone, Self: Clone, Sep: Parser<I, S> + Clone, O: Default + Extend<Self::O>,

Apply the given parser as often as possible, separated by sep. Read more
Source§

fn opt(self) -> Opt<Self>
where I: Clone,

If the given parser succeeds, wrap its output in Some, else return None. Read more
Source§

fn chain<P>( self, other: P, ) -> Map<All<(Self, P)>, fn((<Self as Parser<I, S>>::O, <P as Parser<I, S>>::O)) -> Chain<<Self::O as IntoIterator>::IntoIter, <P::O as IntoIterator>::IntoIter>>
where P: Parser<I, S>, Self::O: IntoIterator, P::O: IntoIterator<Item = <Self::O as IntoIterator>::Item>,

Convert the outputs of the given parsers to iterators and concatenate them. Read more
Source§

fn and_then<P: Parser<I, S>, F: FnOnce(Self::O) -> P>( self, f: F, ) -> AndThen<Self, F>

Run the first parser, then create a second parser from its output and run it.
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, 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.