pub enum ParseResult<'a, TokenKind, T, E> {
Match {
value: T,
remaining: TokenStream<'a, TokenKind>,
},
NoMatch,
Err(E),
}
Expand description
The result of running a parser
Variants§
Match
The input matched the parser pattern.
Fields
§
value: T
The value produced by the parser
§
remaining: TokenStream<'a, TokenKind>
The remaining token stream
NoMatch
The input did not match the parser pattern.
Err(E)
The input matched the parser pattern but was malformed or invalid.
Implementations§
Source§impl<'a, TokenKind, T, E> ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> ParseResult<'a, TokenKind, T, E>
Sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> ParseResult<'a, TokenKind, U, E>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> ParseResult<'a, TokenKind, U, E>
Maps a ParseResult<'a, TokenKind, T, E>
to ParseResult<'a, TokenKind, U, E>
by applying
a function to a contained ParseResult::Match
value, leaving an ParseResult::NoMatch
and ParseResult::Err
value untouched.
Sourcepub fn map_err<F>(
self,
f: impl FnOnce(E) -> F,
) -> ParseResult<'a, TokenKind, T, F>
pub fn map_err<F>( self, f: impl FnOnce(E) -> F, ) -> ParseResult<'a, TokenKind, T, F>
Maps a ParseResult<'a, TokenKind, T, E>
to ParseResult<'a, TokenKind, T, F>
by
applying a function to a contained ParseResult::Err
value, leaving
an ParseResult::Match
and ParseResult::NoMatch
value untouched.
Trait Implementations§
Source§impl<'a, TokenKind, T, E> FromResidual for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> FromResidual for ParseResult<'a, TokenKind, T, E>
Source§impl<'a, TokenKind, T, E> Try for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> Try for ParseResult<'a, TokenKind, T, E>
Source§type Output = (T, TokenStream<'a, TokenKind>)
type Output = (T, TokenStream<'a, TokenKind>)
🔬This is a nightly-only experimental API. (
try_trait_v2
)The type of the value produced by
?
when not short-circuiting.Source§type Residual = ParseResult<'a, TokenKind, Infallible, E>
type Residual = ParseResult<'a, TokenKind, Infallible, E>
🔬This is a nightly-only experimental API. (
try_trait_v2
)The type of the value passed to
FromResidual::from_residual
as part of ?
when short-circuiting. Read moreSource§fn from_output((value, remaining): Self::Output) -> Self
fn from_output((value, remaining): Self::Output) -> Self
🔬This is a nightly-only experimental API. (
try_trait_v2
)Constructs the type from its
Output
type. Read moreSource§fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
fn branch(self) -> ControlFlow<Self::Residual, Self::Output>
🔬This is a nightly-only experimental API. (
try_trait_v2
)Used in
?
to decide whether the operator should produce a value
(because this returned ControlFlow::Continue
)
or propagate a value back to the caller
(because this returned ControlFlow::Break
). Read moreAuto Trait Implementations§
impl<'a, TokenKind, T, E> Freeze for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> RefUnwindSafe for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> Send for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> Sync for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> Unpin for ParseResult<'a, TokenKind, T, E>
impl<'a, TokenKind, T, E> UnwindSafe for ParseResult<'a, TokenKind, T, E>
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