Struct parcours::combinator::Opt

source ·
pub struct Opt<P>(/* private fields */);
Expand description

A parser returned by Combinator::opt.

Trait Implementations§

source§

impl<P: Clone> Clone for Opt<P>

source§

fn clone(&self) -> Opt<P>

Returns a copy 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: Clone, S, P: Parser<I, S>> Parser<I, S> for Opt<P>

§

type O = Option<<P as Parser<I, S>>::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<P> RefUnwindSafe for Opt<P>
where P: RefUnwindSafe,

§

impl<P> Send for Opt<P>
where P: Send,

§

impl<P> Sync for Opt<P>
where P: Sync,

§

impl<P> Unpin for Opt<P>
where P: Unpin,

§

impl<P> UnwindSafe for Opt<P>
where P: 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<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::O, P::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::O, P::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 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>,

§

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>,

§

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.