pub struct Hidden<T>(/* private fields */);Expand description
Wrapper that hides a grammar element from BNF output.
Parses and prints just like the wrapped grammar, but is omitted from BNF. Useful for structural elements like whitespace.
type Ws = Hidden<StringOf<IsSpace>>;Or use #[grammar(hidden)]:
#[derive(Grammar)]
#[grammar(hidden)]
struct Ws(StringOf<IsSpace>);Trait Implementations§
impl<T: Eq> Eq for Hidden<T>
Source§impl<T: Grammar> Grammar for Hidden<T>
impl<T: Grammar> Grammar for Hidden<T>
Source§type First = <OptionalFirst<EmptyByteSet> as First>::Concat<T>
type First = <OptionalFirst<EmptyByteSet> 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<T: Grammar> GrammarRule for Hidden<T>
impl<T: Grammar> GrammarRule for Hidden<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<T> IntoInner<T> for Hidden<T>
impl<T> IntoInner<T> for Hidden<T>
Source§fn into_inner(self) -> T
fn into_inner(self) -> T
Consume
self, discarding whatever structure wrapped T.impl<T: PartialEq> StructuralPartialEq for Hidden<T>
Auto Trait Implementations§
impl<T> Freeze for Hidden<T>where
T: Freeze,
impl<T> RefUnwindSafe for Hidden<T>where
T: RefUnwindSafe,
impl<T> Send for Hidden<T>where
T: Send,
impl<T> Sync for Hidden<T>where
T: Sync,
impl<T> Unpin for Hidden<T>where
T: Unpin,
impl<T> UnsafeUnpin for Hidden<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Hidden<T>where
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