pub struct Prefix<P, T> {
pub prefixed: T,
/* private fields */
}Expand description
Sequence of two grammars, Deref-ing to the second.
Fields§
§prefixed: TThe prefixed value.
Implementations§
Trait Implementations§
impl<P: Eq, T: Eq> Eq for Prefix<P, T>
Source§impl<P: Grammar, T: Grammar> Grammar for Prefix<P, T>
impl<P: Grammar, T: Grammar> Grammar for Prefix<P, T>
Source§type First = <<OptionalFirst<EmptyByteSet> as First>::Concat<P> as First>::Concat<T>
type First = <<OptionalFirst<EmptyByteSet> as First>::Concat<P> as First>::Concat<T>
The set of bytes (and whether empty input is valid) this grammar could start with.
Source§fn parse_at(input: &str, pos: usize, state: State<'_>) -> Option<(Self, usize)>
fn parse_at(input: &str, pos: usize, state: State<'_>) -> Option<(Self, usize)>
Attempt to parse
Self starting at pos, returning the value and the
position just past it, or None on failure.Source§fn scan_at(input: &str, pos: usize, state: State<'_>) -> Option<usize>
fn scan_at(input: &str, pos: usize, state: State<'_>) -> Option<usize>
Like
parse_at, but only checks well-formedness and
returns the end position.Source§fn to_bnf() -> Expr
fn to_bnf() -> Expr
Describe this grammar as a BNF/EBNF expression, for use in a
referencing rule’s own definition.
Source§fn fail_at(pos: usize, state: State<'_>) -> bool
fn fail_at(pos: usize, state: State<'_>) -> bool
Record what this grammar would have expected at
pos, without
attempting to actually parse — used when a caller already knows (e.g.
via First) that this alternative cannot match here, but still wants
it traced. Read moreSource§fn parse(input: &str) -> Result<Self, Error>
fn parse(input: &str) -> Result<Self, Error>
Parse the entire
input as Self, failing if any input is left unconsumed.Source§fn parse_prefix(input: &str) -> Result<(Self, usize), Error>
fn parse_prefix(input: &str) -> Result<(Self, usize), Error>
Like
parse, but doesn’t require consuming all of
input — returns the byte position just past the match, leaving any
remaining input unexamined.Source§fn scan(input: &str) -> Result<(), Error>
fn scan(input: &str) -> Result<(), Error>
Like
parse, but only checks that input is well-formed
and discards the parsed value.Source§impl<P: Grammar, T: Grammar> GrammarRule for Prefix<P, T>
impl<P: Grammar, T: Grammar> GrammarRule for Prefix<P, T>
Source§fn to_bnf_def() -> Expr
fn to_bnf_def() -> Expr
This rule’s own definition, as opposed to
to_bnf,
which is how other rules refer to it.Source§impl<P, T> IntoInner<T> for Prefix<P, T>
impl<P, T> IntoInner<T> for Prefix<P, T>
Source§fn into_inner(self) -> T
fn into_inner(self) -> T
Consume
self, discarding whatever structure wrapped T.impl<P: PartialEq, T: PartialEq> StructuralPartialEq for Prefix<P, T>
Auto Trait Implementations§
impl<P, T> Freeze for Prefix<P, T>
impl<P, T> RefUnwindSafe for Prefix<P, T>where
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<P, T> Send for Prefix<P, T>
impl<P, T> Sync for Prefix<P, T>
impl<P, T> Unpin for Prefix<P, T>
impl<P, T> UnsafeUnpin for Prefix<P, T>where
P: UnsafeUnpin,
T: UnsafeUnpin,
impl<P, T> UnwindSafe for Prefix<P, T>where
P: UnwindSafe,
T: 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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more