pub enum Stmt {
Show 16 variants
Assignment(Assignment),
Command(Command),
Pipeline(Pipeline),
If(IfStmt),
For(ForLoop),
While(WhileLoop),
Case(CaseStmt),
Break(Option<usize>),
Continue(Option<usize>),
Return(Option<Box<Expr>>),
Exit(Option<Box<Expr>>),
ToolDef(ToolDef),
Test(TestExpr),
AndChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
OrChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
Empty,
}Expand description
A single statement in kaish.
Variants§
Assignment(Assignment)
Variable assignment: NAME=value or local NAME = value
Command(Command)
Simple command: tool arg1 arg2
Pipeline(Pipeline)
Pipeline: a | b | c
If(IfStmt)
Conditional: if cond; then ...; fi
For(ForLoop)
Loop: for X in items; do ...; done
While(WhileLoop)
While loop: while cond; do ...; done
Case(CaseStmt)
Case statement: case expr in pattern) ... ;; esac
Break(Option<usize>)
Break out of loop: break or break N
Continue(Option<usize>)
Continue to next iteration: continue or continue N
Return(Option<Box<Expr>>)
Return from tool: return or return expr
Exit(Option<Box<Expr>>)
Exit the script: exit or exit code
ToolDef(ToolDef)
Tool definition: tool name(params) { body }
Test(TestExpr)
Test expression: [[ -f path ]] or [[ $X == "value" ]]
AndChain
Statement chain with &&: run right only if left succeeds
OrChain
Statement chain with ||: run right only if left fails
Empty
Empty statement (newline or semicolon only)
Implementations§
Trait Implementations§
impl StructuralPartialEq for Stmt
Auto Trait Implementations§
impl Freeze for Stmt
impl RefUnwindSafe for Stmt
impl Send for Stmt
impl Sync for Stmt
impl Unpin for Stmt
impl UnsafeUnpin for Stmt
impl UnwindSafe for Stmt
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