pub enum Statement {
Show 17 variants
FunctionDef {
name: String,
parameters: Vec<Parameter>,
return_type: Option<Type>,
body: Vec<Statement>,
},
ClassDef {
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>,
},
While {
test: Expression,
body: Vec<Statement>,
orelse: Vec<Statement>,
},
Break,
Continue,
Pass,
Import {
names: Vec<ImportName>,
},
ImportFrom {
module: Option<String>,
names: Vec<ImportName>,
},
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>,
},
}Expand description
语句
Variants§
FunctionDef
函数定义
ClassDef
类定义
Assignment
变量赋值
AugmentedAssignment
复合赋值 (+=, -=, 等)
Expression(Expression)
表达式语句
Return(Option<Expression>)
返回语句
If
条件语句
For
for 循环
While
while 循环
Break
break 语句
Continue
continue 语句
Pass
pass 语句
Import
import 语句
Fields
§
names: Vec<ImportName>ImportFrom
from import 语句
Try
try 语句
Fields
§
handlers: Vec<ExceptHandler>Raise
raise 语句
With
with 语句
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
创建一个函数定义语句
Sourcepub fn assignment(target: Expression, value: Expression) -> Self
pub fn assignment(target: Expression, value: Expression) -> Self
创建一个赋值语句
Sourcepub fn expression(expr: Expression) -> Self
pub fn expression(expr: Expression) -> Self
创建一个表达式语句
Sourcepub fn return_stmt(value: Option<Expression>) -> Self
pub fn return_stmt(value: Option<Expression>) -> Self
创建一个返回语句
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Statement
impl<'de> Deserialize<'de> for Statement
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Statement
Auto Trait Implementations§
impl Freeze for Statement
impl RefUnwindSafe for Statement
impl Send for Statement
impl Sync for Statement
impl Unpin for Statement
impl UnwindSafe for Statement
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