pub enum PyStmt {
Show 22 variants
Expr(PyExpr),
Assign {
target: PyExpr,
value: PyExpr,
},
AugAssign {
target: PyExpr,
op: BinOp,
value: PyExpr,
},
AnnAssign {
target: PyExpr,
annotation: TypeAnnotation,
value: Option<PyExpr>,
},
FunctionDef {
name: String,
params: Vec<FunctionParam>,
body: Vec<PyStmt>,
return_type: Option<TypeAnnotation>,
decorators: Vec<PyExpr>,
is_async: bool,
},
Return {
value: Option<PyExpr>,
},
If {
test: PyExpr,
body: Vec<PyStmt>,
orelse: Vec<PyStmt>,
},
While {
test: PyExpr,
body: Vec<PyStmt>,
orelse: Vec<PyStmt>,
},
For {
target: PyExpr,
iter: PyExpr,
body: Vec<PyStmt>,
orelse: Vec<PyStmt>,
},
Pass,
Break,
Continue,
ClassDef {
name: String,
bases: Vec<PyExpr>,
body: Vec<PyStmt>,
decorators: Vec<PyExpr>,
},
Import {
modules: Vec<(String, Option<String>)>,
},
ImportFrom {
module: Option<String>,
names: Vec<(String, Option<String>)>,
level: usize,
},
Assert {
test: PyExpr,
msg: Option<PyExpr>,
},
Try {
body: Vec<PyStmt>,
handlers: Vec<ExceptHandler>,
orelse: Vec<PyStmt>,
finalbody: Vec<PyStmt>,
},
Raise {
exception: Option<PyExpr>,
},
With {
items: Vec<WithItem>,
body: Vec<PyStmt>,
},
Delete {
targets: Vec<PyExpr>,
},
Global {
names: Vec<String>,
},
Nonlocal {
names: Vec<String>,
},
}Expand description
Python statement types
Variants§
Expr(PyExpr)
Expression statement
Assign
Assignment: x = 42
AugAssign
Augmented assignment: x += 1
AnnAssign
Annotated assignment: x: int = 42
FunctionDef
Function definition
Return
Return statement
If
If statement
While
While loop
For
For loop
Pass
Pass statement
Break
Break statement
Continue
Continue statement
ClassDef
Class definition
Import
Import statement: import module [as alias]
ImportFrom
From import: from module import name [as alias]
Assert
Assert statement: assert condition, message
Try
Try-except statement
Raise
Raise statement
With
With statement (context manager)
Delete
Delete statement: del x
Global
Global declaration: global x, y
Nonlocal
Nonlocal declaration: nonlocal x, y
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PyStmt
impl<'de> Deserialize<'de> for PyStmt
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 PyStmt
Auto Trait Implementations§
impl Freeze for PyStmt
impl RefUnwindSafe for PyStmt
impl Send for PyStmt
impl Sync for PyStmt
impl Unpin for PyStmt
impl UnwindSafe for PyStmt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more