Struct parcours::combinator::Opt
source · pub struct Opt<P>(/* private fields */);
Expand description
A parser returned by Combinator::opt
.
Trait Implementations§
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> 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
source§impl<I, S, T> Combinator<I, S> for Twhere
T: Parser<I, S>,
impl<I, S, T> Combinator<I, S> for Twhere
T: Parser<I, S>,
source§fn then<P: Parser<I, S>>(self, other: P) -> All<(Self, P)>
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,
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>
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>
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>
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>
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>
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>
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>
fn delimited_by<L, R>( self, l: L, r: R ) -> Map<All<(L, Self, R)>, fn(_: (L::O, Self::O, R::O)) -> Self::O>
Run parsers
l
, self
, and r
in sequence and return only the output of self
.source§fn repeated<O>(self) -> Repeated<Self, fn() -> O>
fn repeated<O>(self) -> Repeated<Self, fn() -> 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>
fn separated_by<Sep, O>(self, sep: Sep) -> SeparatedBy<Self, Sep, fn() -> O>
Apply the given parser as often as possible, separated by
sep
. Read more