Struct parser_compose::Or

source ·
pub struct Or<P1, P2> { /* private fields */ }
Expand description

A parser that succeeds if at least one inner parser succeeds. See or()

Trait Implementations§

source§

impl<In, Out, P1, P2> Parser<In, Out> for Or<P1, P2>where P1: Parser<In, Out>, P2: Parser<In, Out>, In: Clone,

source§

fn try_parse(&self, input: Input<In>) -> Res<In, Out>

Recognizes a value from the input and returns the result Read more
source§

fn map<F, Mapped>(self, f: F) -> Map<Self, F, Out>where Self: Sized, F: Fn(Out) -> Mapped,

Returns a parser that maps a Parser<In, Out> to Parser<In, Mapped> by applying a function to the result of the parser if it succeeded. Read more
source§

fn or<P>(self, next: P) -> Or<Self, P>where Self: Sized,

Returns a parser that succeeds if self does. Otherwise, it’s outcome is that of next. Read more
source§

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 Read more
source§

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 more
source§

fn optional(self) -> Optional<Self>where Self: Sized,

Returns a parser always succeeds but wraps the output in an Option<Out>. If the original parser would have failed, the parser outputs a None. Read more
source§

fn peeked(self) -> Peeked<Self>where Self: Sized,

Returns a parser that succeeds or fails as normal, but never consumes any input regardless of the outcome. This can be used to look ahead. Read more
source§

fn not_peeked(self) -> NotPeeked<Self, Out>where Self: Sized,

Reverse of peeked(). Returns a parse that succeeds if it was not able to recognize the input and fails if it was able to. It never consumes any input. Read more
source§

fn and_then<F, U, E>(self, f: F) -> AndThen<Self, F, Out>where Self: Sized, F: Fn(Out) -> Result<U, E>, E: Error,

Returns a parser that is similar to map() in its behavior, except that the provided closure may fail. The parser reports whatevere error the closure fails with. Read more
source§

fn label(self, l: &'static str) -> Label<Self>where Self: Sized,

Returns an identical parser, but with a label. Labels are used when reporting errors. See ErrorTree for more information.
source§

fn err<E, F>(self, f: F) -> UserErr<Self, F, E>where Self: Sized, F: Fn() -> E, for<'a> E: Error + 'a,

Returns an identical parser that will report the given error when it fails. See ErrorTree for more information on abount error handling

Auto Trait Implementations§

§

impl<P1, P2> RefUnwindSafe for Or<P1, P2>where P1: RefUnwindSafe, P2: RefUnwindSafe,

§

impl<P1, P2> Send for Or<P1, P2>where P1: Send, P2: Send,

§

impl<P1, P2> Sync for Or<P1, P2>where P1: Sync, P2: Sync,

§

impl<P1, P2> Unpin for Or<P1, P2>where P1: Unpin, P2: Unpin,

§

impl<P1, P2> UnwindSafe for Or<P1, P2>where P1: UnwindSafe, P2: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.