pub struct NotFollowedBy<G>(/* private fields */);Expand description
Zero-width negative lookahead: matches the empty string, but only when the following input does not match the wrapped grammar. Consumes nothing and prints nothing.
// "/" that is not the start of a "//" line comment.
#[derive(Grammar)]
struct Div(StringEq!("/"), NotFollowedBy<StringEq!("/")>);
assert!(Div::parse("/").is_ok());
assert!(Div::parse("//").is_err());Trait Implementations§
Source§impl<G> Clone for NotFollowedBy<G>
impl<G> Clone for NotFollowedBy<G>
impl<G> Copy for NotFollowedBy<G>
Source§impl<G> Debug for NotFollowedBy<G>
impl<G> Debug for NotFollowedBy<G>
Source§impl<G> Default for NotFollowedBy<G>
impl<G> Default for NotFollowedBy<G>
impl<G> Eq for NotFollowedBy<G>
Source§impl<G: Grammar> Grammar for NotFollowedBy<G>
impl<G: Grammar> Grammar for NotFollowedBy<G>
Source§type First = OptionalFirst<EmptyByteSet>
type First = OptionalFirst<EmptyByteSet>
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<G> Hash for NotFollowedBy<G>
impl<G> Hash for NotFollowedBy<G>
Auto Trait Implementations§
impl<G> Freeze for NotFollowedBy<G>
impl<G> RefUnwindSafe for NotFollowedBy<G>where
G: RefUnwindSafe,
impl<G> Send for NotFollowedBy<G>where
G: Send,
impl<G> Sync for NotFollowedBy<G>where
G: Sync,
impl<G> Unpin for NotFollowedBy<G>where
G: Unpin,
impl<G> UnsafeUnpin for NotFollowedBy<G>
impl<G> UnwindSafe for NotFollowedBy<G>where
G: 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