pub enum Statement {
Show 24 variants
FunctionDef {
decorators: Vec<Expression>,
name: String,
parameters: Vec<Parameter>,
return_type: Option<Type>,
body: Vec<Statement>,
},
AsyncFunctionDef {
decorators: Vec<Expression>,
name: String,
parameters: Vec<Parameter>,
return_type: Option<Type>,
body: Vec<Statement>,
},
ClassDef {
decorators: Vec<Expression>,
name: String,
bases: Vec<Expression>,
body: Vec<Statement>,
},
Assignment {
target: Expression,
value: Expression,
},
AugmentedAssignment {
target: Expression,
operator: AugmentedOperator,
value: Expression,
},
Expression(Expression),
Return(Option<Expression>),
If {
test: Expression,
body: Vec<Statement>,
orelse: Vec<Statement>,
},
For {
target: Expression,
iter: Expression,
body: Vec<Statement>,
orelse: Vec<Statement>,
},
AsyncFor {
target: Expression,
iter: Expression,
body: Vec<Statement>,
orelse: Vec<Statement>,
},
While {
test: Expression,
body: Vec<Statement>,
orelse: Vec<Statement>,
},
Break,
Continue,
Pass,
Import {
names: Vec<ImportName>,
},
ImportFrom {
module: Option<String>,
names: Vec<ImportName>,
},
Global {
names: Vec<String>,
},
Nonlocal {
names: Vec<String>,
},
Try {
body: Vec<Statement>,
handlers: Vec<ExceptHandler>,
orelse: Vec<Statement>,
finalbody: Vec<Statement>,
},
Raise {
exc: Option<Expression>,
cause: Option<Expression>,
},
With {
items: Vec<WithItem>,
body: Vec<Statement>,
},
AsyncWith {
items: Vec<WithItem>,
body: Vec<Statement>,
},
Assert {
test: Expression,
msg: Option<Expression>,
},
Match {
subject: Expression,
cases: Vec<MatchCase>,
},
}Expand description
Represents a Python statement.
Variants§
FunctionDef
Function definition
Fields
decorators: Vec<Expression>Decorators applied to the function
AsyncFunctionDef
Async function definition
Fields
decorators: Vec<Expression>Decorators applied to the function
ClassDef
Class definition
Fields
decorators: Vec<Expression>Decorators applied to the class
bases: Vec<Expression>Base classes
Assignment
Variable assignment
AugmentedAssignment
Augmented assignment (e.g., +=, -=)
Fields
target: ExpressionTarget expression
operator: AugmentedOperatorAugmented operator
value: ExpressionValue expression
Expression(Expression)
Expression statement
Return(Option<Expression>)
Return statement
If
If statement
Fields
test: ExpressionTest expression
For
For loop
AsyncFor
Async for loop
While
While loop
Fields
test: ExpressionTest expression
Break
Break statement
Continue
Continue statement
Pass
Pass statement
Import
Import statement
Fields
names: Vec<ImportName>List of names being imported
ImportFrom
From-import statement
Fields
names: Vec<ImportName>List of names being imported
Global
Global statement
Nonlocal
Nonlocal statement
Try
Try statement
Fields
handlers: Vec<ExceptHandler>Exception handlers
Raise
Raise statement
With
With statement
AsyncWith
Async with statement
Assert
Assert statement
Match
Match statement
Implementations§
Source§impl Statement
impl Statement
Sourcepub fn function_def(
name: impl Into<String>,
parameters: Vec<Parameter>,
return_type: Option<Type>,
body: Vec<Statement>,
) -> Self
pub fn function_def( name: impl Into<String>, parameters: Vec<Parameter>, return_type: Option<Type>, body: Vec<Statement>, ) -> Self
Creates a function definition statement.
Sourcepub fn assignment(target: Expression, value: Expression) -> Self
pub fn assignment(target: Expression, value: Expression) -> Self
Creates an assignment statement.
Sourcepub fn expression(expr: Expression) -> Self
pub fn expression(expr: Expression) -> Self
Creates an expression statement.
Sourcepub fn return_stmt(value: Option<Expression>) -> Self
pub fn return_stmt(value: Option<Expression>) -> Self
Creates a return statement.