LabelWith

Struct LabelWith 

Source
pub struct LabelWith<P, F> { /* private fields */ }
Expand description

Wrapper that builds labels dynamically from the input.

Trait Implementations§

Source§

impl<P: Clone, F: Clone> Clone for LabelWith<P, F>

Source§

fn clone(&self) -> LabelWith<P, F>

Returns a duplicate 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<P: Debug, F: Debug> Debug for LabelWith<P, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P, F, I, E, N, L, S> Parser<I, E, N, L> for LabelWith<P, F>
where I: Input, E: ErrMode<I> + ErrSink<I, Expected<ErrOf<P, I, E, N, L>>>, N: Rb, L: RbBack, P: Parser<I, E, N, L, Out: OutOf<I, E>>, F: Fn() -> S, S: Into<Cow<'static, str>>,

Source§

fn run(&self, i: In<'_, I, E, N, L>) -> Self::Out

Source§

fn by_ref<'a>(&'a self) -> RefParser<'a, Self>

Borrow a parser immutably as ParserOnce. Read more
Source§

fn flow_many_map<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>, F: for<'a, 'b> Fn(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,

Source§

fn many_map<F, O>(self, f: F) -> ManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> Fn(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like ParserMut::many, but lets you fold via a streaming iterator. Read more
Source§

fn many1_map<F, O>(self, f: F) -> Many1Map<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> Fn(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like Parser::many_map, but requires at least one element.
Source§

fn sep_map<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Value = S, Error = ErrOf<Self, I, E, N, L>>>, F: for<'a, 'b> Fn(SepMapIterator<'a, 'b, Self, Q, I, E, N, L, Zero, Allow>) -> O,

Like ParserMut::sep, but lets you fold via a streaming iterator. Read more
Source§

fn sep1_map<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<One, Allow, Self, Q, F, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Value = S, Error = ErrOf<Self, I, E, N, L>>>, F: for<'a, 'b> Fn(SepMapIterator<'a, 'b, Self, Q, I, E, N, L, One, Allow>) -> O,

Like Parser::sep_map, but requires at least one item (1+). Read more
Source§

fn map<O, F>(self, f: F) -> Map<Self, F>
where Self: Sized, Self::Out: OutOf<I, E>, F: Fn(ValueOf<Self, I, E, N, L>) -> O,

Map the output of a parser. Read more
Source§

fn bind<P2, F>(self, f: F) -> Bind<Self, F>
where Self: Sized, Self::Out: OutOf<I, E>, F: Fn(ValueOf<Self, I, E, N, L>) -> P2, P2: ParserOnce<I, E, N, L, Out: OutOf<I, E, Error = ErrOf<Self, I, E, N, L>>>,

Sequential bind (flat_map). Read more
Source§

impl<P, F, I, E, N, L, S> ParserMut<I, E, N, L> for LabelWith<P, F>
where I: Input, E: ErrMode<I> + ErrSink<I, Expected<ErrOf<P, I, E, N, L>>>, N: Rb, L: RbBack, P: ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: FnMut() -> S, S: Into<Cow<'static, str>>,

Source§

fn run_mut(&mut self, i: In<'_, I, E, N, L>) -> Self::Out

Source§

fn by_mut<'a>(&'a mut self) -> MutParser<'a, Self>

Borrow a parser mutably as ParserOnce. Read more
Source§

fn map_mut<O, F>(self, f: F) -> Map<Self, F>
where Self: Sized, Self::Out: OutOf<I, E>, F: FnMut(ValueOf<Self, I, E, N, L>) -> O,

Like Parser::map, but intended for mutable/repeatable mappers (FnMut).
Source§

fn bind_mut<P2, F>(self, f: F) -> Bind<Self, F>
where Self: Sized, Self::Out: OutOf<I, E>, F: FnMut(ValueOf<Self, I, E, N, L>) -> P2, P2: ParserOnce<I, E, N, L, Out: OutOf<I, E, Error = ErrOf<Self, I, E, N, L>>>,

Like Parser::bind, but intended for mutable/repeatable binders (FnMut).
Source§

fn flow<C, S, Step, T>(self, state: S, step: Step) -> Flow<Self, S, Step>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Step: FnMut(S, T) -> ControlFlow<C, S>,

Stateful loop that terminates on soft failure via In::maybe. Read more
Source§

fn flow_many<O, T1, T2>(self) -> FlowMany<Self, O>
where Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>, O: FromIterator<T1>,

Collect Continue(T1) values until Break(T2). Read more
Source§

fn flow_many_map_once<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>, F: for<'a, 'b> FnOnce(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,

Like Parser::flow_many_map, but intended for single-shot mappers (FnOnce).
Source§

fn flow_many_map_mut<F, O, T1, T2>(self, f: F) -> FlowManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out = ControlFlow<T2, T1>>, F: for<'a, 'b> FnMut(&mut FlowManyIterator<'a, 'b, Self, I, E, N, L, T1, T2>) -> O,

Like Parser::flow_many_map, but intended for mutable/repeatable mappers (FnMut).
Source§

fn many<O>(self) -> Many<Self, O>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, O: FromIterator<ValueOf<Self, I, E, N, L>>,

Repeat a parser until soft failure, collecting outputs. Read more
Source§

fn many1<O>(self) -> Many1<Self, O>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, O: FromIterator<ValueOf<Self, I, E, N, L>>,

Repeat a parser one or more times, collecting outputs. Read more
Source§

fn many_map_once<F, O>(self, f: F) -> ManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> FnOnce(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like Parser::many_map, but intended for single-shot mappers (FnOnce).
Source§

fn many_map_mut<F, O>(self, f: F) -> ManyMap<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> FnMut(ManyMapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like Parser::many_map, but intended for mutable/repeatable mappers (FnMut). Read more
Source§

fn many1_map_once<F, O>(self, f: F) -> Many1Map<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> FnOnce(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like Parser::many1_map, but intended for single-shot mappers (FnOnce).
Source§

fn many1_map_mut<F, O>(self, f: F) -> Many1Map<Self, F>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, F: for<'a, 'b> FnMut(Many1MapIterator<'a, 'b, Self, I, E, N, L>) -> O,

Like Parser::many1_map, but intended for mutable/repeatable mappers (FnMut).
Source§

fn many_skip(self) -> SkipMany<Self>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,

Repeat a parser until soft failure, discarding outputs. Read more
Source§

fn many1_skip(self) -> SkipMany1<Self>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>,

Repeat a parser one or more times, discarding outputs. Read more
Source§

fn count<R, O>(self, range: R) -> Count<Self, O>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E>>, R: CountRange, O: FromIterator<ValueOf<Self, I, E, N, L>>,

Repeat a parser a specified number of times. Read more
Source§

fn sep<O, Q, T>(self, sep_p: Q) -> Sep<O, Zero, Allow, Self, Q, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Error = ErrOf<Self, I, E, N, L>>>, O: FromIterator<T>,

Parse a separated list: item (sep item)*. Read more
Source§

fn sep1<O, Q, T>(self, sep_p: Q) -> Sep<O, One, Allow, Self, Q, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Error = ErrOf<Self, I, E, N, L>>>, O: FromIterator<T>,

Like ParserMut::sep, but requires at least one item (1+). Read more
Source§

fn sep_map_once<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Value = S, Error = ErrOf<Self, I, E, N, L>>>, F: for<'a, 'b> FnOnce(SepMapIterator<'a, 'b, Self, Q, I, E, N, L, Zero, Allow>) -> O,

Like Parser::sep_map, but intended for single-shot mappers (FnOnce).
Source§

fn sep_map_mut<Q, F, T, S, O>( self, sep_p: Q, f: F, ) -> SepMap<Zero, Allow, Self, Q, F, T>
where Self: Sized + ParserMut<I, E, N, L, Out: OutOf<I, E, Value = T>>, Q: ParserMut<I, E, N, L, Out: OutOf<I, E, Value = S, Error = ErrOf<Self, I, E, N, L>>>, F: for<'a, 'b> FnMut(SepMapIterator<'a, 'b, Self, Q, I, E, N, L, Zero, Allow>) -> O,

Like Parser::sep_map, but intended for mutable/repeatable mappers (FnMut).
Source§

fn sep_reduce<Q, F>(self, op: Q, f: F) -> SepReduce<Self, Q, F>

Left-associative separator reduction: term (op term)*. let mut input = “a+a+a”; let term = item(‘a’).to(1); let plus = item(‘+’).to(()); let out = parse_ok_once(&mut input, term.sep_reduce(plus, |a, _, b| a + b)).unwrap(); assert_eq!(out, 3); assert_eq!(input, “”); Read more
Source§

impl<P, F, I, E, N, L, S> ParserOnce<I, E, N, L> for LabelWith<P, F>
where I: Input, E: ErrMode<I> + ErrSink<I, Expected<ErrOf<P, I, E, N, L>>>, N: Rb, L: RbBack, P: ParserOnce<I, E, N, L, Out: OutOf<I, E>>, F: FnOnce() -> S, S: Into<Cow<'static, str>>,

Source§

type Out = <E as ErrMode<I>>::Out<<<P as ParserOnce<I, E, N, L>>::Out as OutOf<I, E>>::Value, Expected<<<P as ParserOnce<I, E, N, L>>::Out as OutOf<I, E>>::Error>>

Source§

fn run_once(self, i: In<'_, I, E, N, L>) -> Self::Out

Source§

fn or_not(self) -> OrNot<Self>

Optionalize a parser with OutOf semantics. Read more
Source§

fn cut(self) -> CutIfOk<Self>
where Self::Out: OutOf<I, E>,

Commit-on-success for OutOf parsers. Read more
Source§

fn with_range(self) -> WithRange<Self>
where Self::Out: OutOf<I, E>,

Attach the consumed range (start and end positions) to a parser output. Read more
Source§

fn with_seq<S>(self) -> WithSeq<Self, S>
where Self::Out: OutOf<I, E>,

Attach the consumed sequence to a parser output. Read more
Source§

fn lookahead(self) -> Lookahead<Self>
where Self::Out: OutOf<I, E>,

Run this parser as lookahead. Read more
Source§

fn no_cut(self) -> NoCut<Self>

Run this parser in a non-root cut scope (cut does not trigger commits). Read more
Source§

fn not(self) -> Not<Self>
where Self::Out: OutOf<I, E>,

Negative lookahead for OutOf parsers. Read more
Source§

fn label(self, label: impl Into<Cow<'static, str>>) -> Label<Self>

Attach a label to a parser failure (Parsec-like <?>). Read more
Source§

fn label_with<F, S>(self, f: F) -> LabelWith<Self, F>
where F: Fn() -> S, S: Into<Cow<'static, str>>,

Attach a lazily-evaluated label to a parser failure. Read more
Source§

fn label_with_once<F, S>(self, f: F) -> LabelWith<Self, F>
where F: FnOnce() -> S, S: Into<Cow<'static, str>>,

Like ParserOnce::label_with, but intended for single-shot label builders (FnOnce).
Source§

fn label_with_mut<F, S>(self, f: F) -> LabelWith<Self, F>
where F: FnMut() -> S, S: Into<Cow<'static, str>>,

Like ParserOnce::label_with, but intended for mutable/repeatable label builders (FnMut).
Source§

fn align_errors<T, E2>(self) -> AlignErrors<Self, (T, E2)>
where I: SeqInput<T>, E2: MergeErrors, Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,

Align and merge errors, returning the consumed sequence on failure.
Source§

fn align_ranged_errors<T, E2>(self) -> AlignRangedErrors<Self, (T, E2)>
where I: SeqInput<T>, E2: MergeErrors, Self: ParserOnce<I, Merger<I, E2>, N, L, Out: OutOf<I, Merger<I, E2>>>,

Align and merge errors, returning the consumed sequence and range on failure.
Source§

fn map_once<O, F>(self, f: F) -> Map<Self, F>
where Self::Out: OutOf<I, E>, F: FnOnce(ValueOf<Self, I, E, N, L>) -> O,

Like Parser::map, but intended for single-shot mappers (FnOnce).
Source§

fn lift_result<O, E1>(self) -> LiftResult<Self>
where Self: ParserOnce<I, (), N, L, Out = Result<O, E1>>,

Lift a direct Result output into a merger-based parser with ranged errors.
Source§

fn lift_ranged_result<O1, O2, E1>(self) -> LiftRangedResult<Self>
where Self: ParserOnce<I, (), N, L, Out = (O1, Result<O2, (Range<I::Pos>, E1)>)>,

Lift a direct (A, Result<B, (range, err)>) output into a merger-based parser.
Source§

fn to<O>(self, value: O) -> To<Self, O>
where Self::Out: OutOf<I, E>,

Replace the output of a parser with a constant value. Read more
Source§

fn bind_once<P2, F>(self, f: F) -> Bind<Self, F>
where Self::Out: OutOf<I, E>, F: FnOnce(ValueOf<Self, I, E, N, L>) -> P2, P2: ParserOnce<I, E, N, L, Out: OutOf<I, E, Error = ErrOf<Self, I, E, N, L>>>,

Like Parser::bind, but intended for single-shot binders (FnOnce).
Source§

fn then<P>(self, right: P) -> (Self, P)

Parse self then right, returning both outputs as a tuple. Read more
Source§

fn left<P>(self, right: P) -> Left<Self, P>

Parse self then right, returning the output of self. Read more
Source§

fn right<P>(self, right: P) -> Right<Self, P>

Parse self then right, returning the output of right. Read more
Source§

fn between<Lp, Rp>(self, left: Lp, right: Rp) -> Between<Lp, Self, Rp>

Parse left, then self, then right, returning the output of self. Read more
Source§

fn or<P>(self, other: P) -> Choice<(Self, P)>
where Self::Out: OutOf<I, E>, P: ParserOnce<I, E, N, L, Out = Self::Out>,

Choice: try self, then other on soft failure. Read more
Source§

fn map_err<E1, E2, E3, F, O>(self, f: F) -> MapErr<Self, F, (O, E1)>
where Self: ParserOnce<I, Merger<I, E1>, N, L, Out = Option<O>>, F: FnOnce(&[E1]) -> E2, E2: Into<E3>,

Auto Trait Implementations§

§

impl<P, F> Freeze for LabelWith<P, F>
where P: Freeze, F: Freeze,

§

impl<P, F> RefUnwindSafe for LabelWith<P, F>

§

impl<P, F> Send for LabelWith<P, F>
where P: Send, F: Send,

§

impl<P, F> Sync for LabelWith<P, F>
where P: Sync, F: Sync,

§

impl<P, F> Unpin for LabelWith<P, F>
where P: Unpin, F: Unpin,

§

impl<P, F> UnwindSafe for LabelWith<P, F>
where P: UnwindSafe, F: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Back for T
where T: Clone,

Source§

type Checkpoint = T

A clonable checkpoint that can restore the input to an earlier state.
Source§

fn checkpoint(&mut self) -> <T as Back>::Checkpoint

Create a rollback checkpoint.
Source§

fn rollback(&mut self, checkpoint: <T as Back>::Checkpoint)

Roll back the input to a previously created checkpoint.
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.