pub struct ToParser<Match, Output> { /* private fields */ }Expand description
Parser produced by MatcherCombinator::to.
It runs a matcher and returns a fixed output value when the matcher succeeds.
The matcher is evaluated with an empty capture result, so this is intended for
ordinary matchers, not bind!/bind_span!/bind_slice! capture binders.
Implementations§
Trait Implementations§
Source§impl<Match, Output> ParserCombinator for ToParser<Match, Output>
impl<Match, Output> ParserCombinator for ToParser<Match, Output>
Source§fn memoized<T>(self) -> Memoized<Self, T>where
Self: Sized,
fn memoized<T>(self) -> Memoized<Self, T>where
Self: Sized,
Memoize parse results of type T keyed by input position (including outputs that borrow the input).
Source§fn recover_with<RecoveryParser>(
self,
recover_parser: RecoveryParser,
) -> ErrorRecovererInner<Self, RecoveryParser>where
Self: Sized,
fn recover_with<RecoveryParser>(
self,
recover_parser: RecoveryParser,
) -> ErrorRecovererInner<Self, RecoveryParser>where
Self: Sized,
On parse failure, run
recover_matcher and yield recover_output if it matches.Source§fn add_error_info<Pars>(
self,
error_parser: Pars,
) -> ErrorContextualizer<Self, Pars>where
Self: Sized,
fn add_error_info<Pars>(
self,
error_parser: Pars,
) -> ErrorContextualizer<Self, Pars>where
Self: Sized,
Available on crate feature
parser-trace only.Enrich hard failures from this parser with additional local context.
Source§fn ignore_result(self) -> IgnoreResult<Self>where
Self: Sized,
fn ignore_result(self) -> IgnoreResult<Self>where
Self: Sized,
Available on crate feature
parser-trace only.Run this parser as a matcher and discard the output.
Source§fn map_output<MapFn>(self, map_fn: MapFn) -> OutputMapper<Self, MapFn>where
Self: Sized,
fn map_output<MapFn>(self, map_fn: MapFn) -> OutputMapper<Self, MapFn>where
Self: Sized,
Map each successful parser output with
map_fn, preserving parse behavior.Auto Trait Implementations§
impl<Match, Output> Freeze for ToParser<Match, Output>
impl<Match, Output> RefUnwindSafe for ToParser<Match, Output>where
Match: RefUnwindSafe,
Output: RefUnwindSafe,
impl<Match, Output> Send for ToParser<Match, Output>
impl<Match, Output> Sync for ToParser<Match, Output>
impl<Match, Output> Unpin for ToParser<Match, Output>
impl<Match, Output> UnsafeUnpin for ToParser<Match, Output>where
Match: UnsafeUnpin,
Output: UnsafeUnpin,
impl<Match, Output> UnwindSafe for ToParser<Match, Output>where
Match: UnwindSafe,
Output: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<'src, Inp, P> Parser<'src, Inp> for Pwhere
Inp: Input<'src>,
P: ParserImpl<'src, Inp> + 'src,
impl<'src, Inp, P> Parser<'src, Inp> for Pwhere
Inp: Input<'src>,
P: ParserImpl<'src, Inp> + 'src,
Source§fn parse_whole_input(
&self,
input: Inp,
) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>), FurthestFailError>
fn parse_whole_input( &self, input: Inp, ) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>), FurthestFailError>
Parse all of
input with the default whole-input + EOF crate::matcher::commit_matcher::commit_on
wrapper (same driver as crate::parse for Inp = &'src str).Source§fn parse_str(
&self,
src: &'src str,
) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>), FurthestFailError>
fn parse_str( &self, src: &'src str, ) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>), FurthestFailError>
Like
Self::parse_whole_input for string input (convenience alias).Source§fn parse_whole_input_with_trace(
&self,
input: Inp,
) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
fn parse_whole_input_with_trace( &self, input: Inp, ) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
Available on crate feature
parser-trace only.Parse with tracing; same whole-input + EOF wrapper as
Self::parse_whole_input.Source§fn parse_whole_input_with_trace_session(
&self,
input: Inp,
trace_session: TraceSession,
) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
fn parse_whole_input_with_trace_session( &self, input: Inp, trace_session: TraceSession, ) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
Available on crate feature
parser-trace only.Like
Self::parse_whole_input_with_trace, reusing an existing TraceSession.Source§fn parse_str_with_trace(
&self,
src: &'src str,
) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
fn parse_str_with_trace( &self, src: &'src str, ) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>, TraceSession), FurthestFailError>
Available on crate feature
parser-trace only.Convenience alias for
Self::parse_whole_input_with_trace on string input.Source§fn parse_whole_input_with_trace_to_file(
&self,
input: Inp,
trace_path: impl AsRef<Path>,
format: TraceFormat,
) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>), ParseWithTraceToFileError>
fn parse_whole_input_with_trace_to_file( &self, input: Inp, trace_path: impl AsRef<Path>, format: TraceFormat, ) -> Result<(<Self as ParserImpl<'src, Inp>>::Output, Vec<ParserError>), ParseWithTraceToFileError>
Available on crate feature
parser-trace only.Traced parse and write the session to
trace_path (no source snapshot; spans are positions in input).Source§fn parse_str_with_trace_to_file(
&self,
src: &'src str,
trace_path: impl AsRef<Path>,
format: TraceFormat,
) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>), ParseWithTraceToFileError>
fn parse_str_with_trace_to_file( &self, src: &'src str, trace_path: impl AsRef<Path>, format: TraceFormat, ) -> Result<(<Self as ParserImpl<'src, &'src str>>::Output, Vec<ParserError>), ParseWithTraceToFileError>
Available on crate feature
parser-trace only.Like
Self::parse_whole_input_with_trace_to_file, and records src as trace source text.