Skip to main content

CompoundKind

Enum CompoundKind 

Source
#[non_exhaustive]
pub enum CompoundKind<'a> { For { var: &'a str, words: Option<Vec<Word<'a>>>, body: Vec<Cmd<'a>>, }, While(GuardBody<'a>), Until(GuardBody<'a>), If { conditionals: Vec<GuardBody<'a>>, else_branch: Option<Vec<Cmd<'a>>>, }, Case { word: Word<'a>, arms: Vec<CaseArm<'a>>, }, CFor { init: Option<Arith<'a>>, cond: Option<Arith<'a>>, step: Option<Arith<'a>>, body: Vec<Cmd<'a>>, }, Brace(Vec<Cmd<'a>>), Subshell(Vec<Cmd<'a>>), DoubleBracket(Vec<Cmd<'a>>), Arithmetic(Arith<'a>), }
Expand description

The body of a compound command.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

For

for var [in words]; do body; done

Fields

§var: &'a str

Loop variable name.

§words: Option<Vec<Word<'a>>>

Word list (None = "$@").

§body: Vec<Cmd<'a>>

Loop body commands.

§

While(GuardBody<'a>)

while guard; do body; done

§

Until(GuardBody<'a>)

until guard; do body; done

§

If

if cond; then body; [elif ...;] [else ...;] fi

Fields

§conditionals: Vec<GuardBody<'a>>

Condition–body pairs (first is if, rest are elif).

§else_branch: Option<Vec<Cmd<'a>>>

Optional else branch.

§

Case

case word in pattern) body;; ... esac

Fields

§word: Word<'a>

The word being matched.

§arms: Vec<CaseArm<'a>>

Pattern–body arms.

§

CFor

C-style for loop: for (( init; cond; step )); do body; done

Fields

§init: Option<Arith<'a>>

Initialization expression.

§cond: Option<Arith<'a>>

Condition expression.

§step: Option<Arith<'a>>

Step expression.

§body: Vec<Cmd<'a>>

Loop body commands.

§

Brace(Vec<Cmd<'a>>)

{ body; } — brace group.

§

Subshell(Vec<Cmd<'a>>)

( body ) — subshell.

§

DoubleBracket(Vec<Cmd<'a>>)

[[ expression ]] — extended test command.

§

Arithmetic(Arith<'a>)

(( expression )) — arithmetic command.

Trait Implementations§

Source§

impl<'a> Clone for CompoundKind<'a>

Source§

fn clone(&self) -> CompoundKind<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for CompoundKind<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for CompoundKind<'a>

Source§

fn eq(&self, other: &CompoundKind<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for CompoundKind<'a>

Source§

impl<'a> StructuralPartialEq for CompoundKind<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for CompoundKind<'a>

§

impl<'a> RefUnwindSafe for CompoundKind<'a>

§

impl<'a> Send for CompoundKind<'a>

§

impl<'a> Sync for CompoundKind<'a>

§

impl<'a> Unpin for CompoundKind<'a>

§

impl<'a> UnsafeUnpin for CompoundKind<'a>

§

impl<'a> UnwindSafe for CompoundKind<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.