pub struct Optional<P> { /* private fields */ }
Expand description

Trait Implementations§

source§

impl<P: Clone> Clone for Optional<P>

source§

fn clone(&self) -> Optional<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<In, Out, P> Parser<In> for Optional<P>where In: Clone, P: Parser<In, Out = Out>,

§

type Out = Option<Out>

The type this parser outputs if successful
source§

fn try_parse(&self, ctx: ParserContext<In>) -> Res<In, Self::Out>

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

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

Returns a parser that applies the the function f to its output Read more
source§

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

Returns a parser that calls the next parser if it failed to match its input. Read more
source§

fn when<F>(self, pred: F) -> Predicate<Self, F>where Self: Sized, F: Fn(Self::Out) -> bool,

Returns a parser that only succeeds if pred returns true when given the parser’s output Read more
source§

fn fold<R, Op, Init, IV>( self, count: R, op: Op, init: Init ) -> Fold<Self, Op, Init>where R: RepetitionArgument, Init: Fn() -> IV, Op: Fn(IV, Self::Out) -> IV, Self: Sized,

Returns a parser that succeeds if it is able to match its input count times. Read more
source§

fn skim<R>(self, count: R) -> Fold<Self, fn(_: (), _: Self::Out), fn()>where Self: Sized, R: RepetitionArgument,

Returns a parser that succeeds if it is able to match its input count times, discarding any output along the way Read more
source§

fn accumulate<R>( self, count: R ) -> Fold<Self, fn(_: Vec<Self::Out>, _: Self::Out) -> Vec<Self::Out>, fn() -> Vec<Self::Out>>where R: RepetitionArgument, Self: Sized,

Returns a parser that succeeds if it is able to match its input count times, accumulating output into a Vec along the way. Read more
source§

fn input(self) -> Input<Self>where Self: Sized,

Returns a parser that outputs the slice of the input that was recognized. Read more
source§

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

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

fn peek(self) -> Peek<Self>where Self: Sized,

Returns a parser that never consumes any input regardless of its outcome. It can be used to look ahead. Read more
source§

fn not(self) -> Not<Self>where Self: Sized,

Returns a parser that succeeds if it was not able to recognize its 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>where Self: Sized, F: Fn(Self::Out) -> Result<U, E>, E: Error,

Returns a parser that applies a falible function f to its output. The parser will report whatever error f fails with. Read more
source§

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

Returns a parser with a label that will be printed should it fail. See ErrorTree for more information.
source§

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

Returns a parser that will report the given error when it fails. See ErrorTree for more information.
source§

impl<P: Copy> Copy for Optional<P>

Auto Trait Implementations§

§

impl<P> RefUnwindSafe for Optional<P>where P: RefUnwindSafe,

§

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

§

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

§

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

§

impl<P> UnwindSafe for Optional<P>where P: 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.