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

AliasSubstituted

Result of alias substitution.

Parsed(T)

Successful parse result.

Implementations

Tests if self is AliasSubstituted.

Extracts the result of successful parsing.

Panics

If self is AliasSubstituted.

Transforms the result value in self.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.