Struct parser_compose::Predicate
source · pub struct Predicate<P, F> { /* private fields */ }
Expand description
A parser that only succeeds if it does not report an error and the predicate returns true
.
See when()
Trait Implementations§
source§impl<In, Out, E, P, F> Parser<In, Out, E> for Predicate<P, F>where
P: Parser<In, Out, E>,
F: Fn(&Out) -> bool,
impl<In, Out, E, P, F> Parser<In, Out, E> for Predicate<P, F>where P: Parser<In, Out, E>, F: Fn(&Out) -> bool,
source§fn try_parse(&self, input: In) -> Res<In, Out, E>
fn try_parse(&self, input: In) -> Res<In, Out, E>
Recognizes a value from the input and returns the result Read more
source§fn map<F, M>(self, f: F) -> Map<Self, F, Out>where
Self: Sized,
F: Fn(Out) -> M,
fn map<F, M>(self, f: F) -> Map<Self, F, Out>where Self: Sized, F: Fn(Out) -> M,
Returns a new parser that calls the closure if it succeeds, providing the extracted value
as an argument
source§fn map_err<F, M>(self, f: F) -> MapErr<Self, F, E>where
Self: Sized,
F: Fn(Error<E>) -> Error<M>,
fn map_err<F, M>(self, f: F) -> MapErr<Self, F, E>where Self: Sized, F: Fn(Error<E>) -> Error<M>,
Returns a new parser which that calls the closure if it fails, providing the
error as an argument
source§fn or<P>(self, next: P) -> Or<Self, P>where
Self: Sized,
fn or<P>(self, next: P) -> Or<Self, P>where Self: Sized,
Returns a new parser that succeeds when either the current or the
next
parser succeedsource§fn when<F>(self, pred: F) -> Predicate<Self, F>where
Self: Sized,
F: Fn(&Out) -> bool,
fn when<F>(self, pred: F) -> Predicate<Self, F>where Self: Sized, F: Fn(&Out) -> bool,
Returns a new parser that succeeds if the predicate returns true. The predicate is given
the extracted value of the current parser as an argument
source§fn repeated<R: RepetitionArgument>(self, count: R) -> Repeat<Self, R>where
Self: Sized,
fn repeated<R: RepetitionArgument>(self, count: R) -> Repeat<Self, R>where Self: Sized,
Returns a parser that suceeds if it is able to repeat
count
times. Read moresource§fn optional(self) -> Optional<Self>where
Self: Sized,
fn optional(self) -> Optional<Self>where Self: Sized,
Returns a parser that succeeds even if it does not not recognize the input
source§fn peeked(self) -> Peeked<Self>where
Self: Sized,
fn peeked(self) -> Peeked<Self>where Self: Sized,
Returns a parser that succeeds or fails with inner parser, but never consumes any input
regardless of the outcome
fn and_then<F, U>(self, f: F) -> AndThen<Self, F, Out>where Self: Sized, F: Fn(Out) -> Result<U, Error<E>>,
Auto Trait Implementations§
impl<P, F> RefUnwindSafe for Predicate<P, F>where F: RefUnwindSafe, P: RefUnwindSafe,
impl<P, F> Send for Predicate<P, F>where F: Send, P: Send,
impl<P, F> Sync for Predicate<P, F>where F: Sync, P: Sync,
impl<P, F> Unpin for Predicate<P, F>where F: Unpin, P: Unpin,
impl<P, F> UnwindSafe for Predicate<P, F>where F: UnwindSafe, 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