pub enum Rec<T> {
AliasSubstituted,
Parsed(T),
}
Expand description
Modifier that makes a result of parsing optional in order to trigger the parser to restart parsing after alias substitution
Rec
stands for “recursion”, as it is used to make the parser work recursively.
This enum type has two variants: AliasSubstituted
and Parsed
. The former contains no
meaningful value and is returned from a parsing function that has performed alias substitution
without consuming any tokens. In this case, the caller of the parsing function must inspect the
new source code produced by the substitution so that the syntax is correctly recognized in the
new code.
Assume we have an alias definition untrue='! true'
, for example. When the word untrue
is
recognized as an alias name during parse of a simple command, the simple command parser
function must stop parsing and return AliasSubstituted
. This allows the caller, the pipeline
parser function, to recognize the !
reserved word token as negation.
When a parser function successfully parses something, it returns the result in the Parsed
variant. The caller then continues the remaining parse.
Variants§
Implementations§
Trait Implementations§
impl<T: Copy> Copy for Rec<T>
impl<T: Eq> Eq for Rec<T>
impl<T> StructuralPartialEq for Rec<T>
Auto Trait Implementations§
impl<T> Freeze for Rec<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rec<T>where
T: RefUnwindSafe,
impl<T> Send for Rec<T>where
T: Send,
impl<T> Sync for Rec<T>where
T: Sync,
impl<T> Unpin for Rec<T>where
T: Unpin,
impl<T> UnwindSafe for Rec<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
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>
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>
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