pub enum TextUnit {
    Literal(char),
    Backslashed(char),
    RawParam {
        name: String,
        location: Location,
    },
    BracedParam(Param),
    CommandSubst {
        content: Rc<str>,
        location: Location,
    },
    Backquote {
        content: Vec<BackquoteUnit>,
        location: Location,
    },
    Arith {
        content: Text,
        location: Location,
    },
}
Expand description

Element of a Text, i.e., something that can be expanded.

Variants

Literal(char)

Literal single character.

Backslashed(char)

Backslash-escaped single character.

RawParam

Fields

name: String

Parameter name.

location: Location

Position of this parameter expansion in the source code.

Parameter expansion that is not enclosed in braces.

BracedParam(Param)

Parameter expansion that is enclosed in braces.

CommandSubst

Fields

content: Rc<str>

Command string that will be parsed and executed when the command substitution is expanded.

This value is reference-counted so that the shell does not have to clone the entire string when it is passed to a subshell to execute the command substitution.

location: Location

Position of this command substitution in the source code.

Command substitution of the form $(...).

Backquote

Fields

content: Vec<BackquoteUnit>

Command string that will be parsed and executed when the command substitution is expanded.

location: Location

Position of this command substitution in the source code.

Command substitution of the form `...`.

Arith

Fields

content: Text

Expression that is to be evaluated.

location: Location

Position of this arithmetic expansion in the source code.

Arithmetic expansion.

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
Formats the value using the given formatter. Read more

Parses a TextUnit by lexer.text_unit(|_| false, |_| true).

The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more

If self is Literal, appends the character to result and returns Ok(result). Otherwise, returns Err(result).

Checks if self is literal and, if so, converts to a string.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Converts self to a string with all quotes removed and writes to w.
Converts self to a string with all quotes removed. Read more

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
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. 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.