pub struct Attempt<'input, T: 'input + ?Sized, R: Rule<'input, T>>(pub R, _);
Expand description
Attempts to parse a rule, returning its result. See Rule::attempt
.
Tuple Fields§
§0: R
Trait Implementations§
source§impl<'input, T: 'input + ?Sized, R: Rule<'input, T>> Rule<'input, T> for Attempt<'input, T, R>
impl<'input, T: 'input + ?Sized, R: Rule<'input, T>> Rule<'input, T> for Attempt<'input, T, R>
source§type Output = Result<<R as Rule<'input, T>>::Output, ParseError>
type Output = Result<<R as Rule<'input, T>>::Output, ParseError>
The type of the value of a successful parse of this rule.
source§fn parse_at<'cursor, 'this, 'index>(
&'this self,
input: &'cursor mut &'input T,
index: &'index mut usize,
) -> Result<Self::Output, ParseError>where
'input: 'this,
fn parse_at<'cursor, 'this, 'index>(
&'this self,
input: &'cursor mut &'input T,
index: &'index mut usize,
) -> Result<Self::Output, ParseError>where
'input: 'this,
Parses a rule at a given index with a given input. Read more
source§fn parse<'this>(
&'this self,
input: &'input SliceType,
) -> Result<(&'input SliceType, Self::Output), ParseError>where
'input: 'this,
fn parse<'this>(
&'this self,
input: &'input SliceType,
) -> Result<(&'input SliceType, Self::Output), ParseError>where
'input: 'this,
Parses a given rule at the start of some input. Read more
source§fn map_parsed<Output, F: Fn(Self::Output) -> Output>(
self,
function: F,
) -> Map<'input, SliceType, Self, Output, F>where
Self: Sized,
fn map_parsed<Output, F: Fn(Self::Output) -> Output>(
self,
function: F,
) -> Map<'input, SliceType, Self, Output, F>where
Self: Sized,
Maps an infallible function onto the output of a rule.
source§fn try_map_parsed<Output, E: Error + 'static, F: Fn(Self::Output) -> Result<Output, E>>(
self,
function: F,
) -> TryMap<'input, SliceType, Self, Output, E, F>where
Self: Sized,
fn try_map_parsed<Output, E: Error + 'static, F: Fn(Self::Output) -> Result<Output, E>>(
self,
function: F,
) -> TryMap<'input, SliceType, Self, Output, E, F>where
Self: Sized,
Maps a function onto the output of a rule, passing the error back if it fails.
source§fn repeat_for<const REPS: usize>(
self,
) -> RepeatFor<'input, SliceType, Self, REPS>where
Self: Sized,
fn repeat_for<const REPS: usize>(
self,
) -> RepeatFor<'input, SliceType, Self, REPS>where
Self: Sized,
Repeats this rule a known amount of times.
source§fn repeat(self, reps: usize) -> Repeat<'input, SliceType, Self>where
Self: Sized,
fn repeat(self, reps: usize) -> Repeat<'input, SliceType, Self>where
Self: Sized,
Repeats this rule a set amount of times.
source§fn take(self, at_most: usize) -> Many<'input, SliceType, Self>where
Self: Sized,
fn take(self, at_most: usize) -> Many<'input, SliceType, Self>where
Self: Sized,
Repeats this rule at most a set amount of times.
Auto Trait Implementations§
impl<'input, T, R> Freeze for Attempt<'input, T, R>
impl<'input, T, R> RefUnwindSafe for Attempt<'input, T, R>
impl<'input, T, R> Send for Attempt<'input, T, R>
impl<'input, T, R> Sync for Attempt<'input, T, R>
impl<'input, T, R> Unpin for Attempt<'input, T, R>
impl<'input, T, R> UnwindSafe for Attempt<'input, T, R>
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