pub enum Expression {
Show 18 variants
Literal(Literal),
Name(String),
BinaryOp {
left: Box<Expression>,
operator: BinaryOperator,
right: Box<Expression>,
},
UnaryOp {
operator: UnaryOperator,
operand: Box<Expression>,
},
BoolOp {
operator: BoolOperator,
values: Vec<Expression>,
},
Compare {
left: Box<Expression>,
ops: Vec<CompareOperator>,
comparators: Vec<Expression>,
},
Call {
func: Box<Expression>,
args: Vec<Expression>,
keywords: Vec<Keyword>,
},
Attribute {
value: Box<Expression>,
attr: String,
},
Subscript {
value: Box<Expression>,
slice: Box<Expression>,
},
List {
elts: Vec<Expression>,
},
Tuple {
elts: Vec<Expression>,
},
Dict {
keys: Vec<Option<Expression>>,
values: Vec<Expression>,
},
Set {
elts: Vec<Expression>,
},
ListComp {
elt: Box<Expression>,
generators: Vec<Comprehension>,
},
DictComp {
key: Box<Expression>,
value: Box<Expression>,
generators: Vec<Comprehension>,
},
SetComp {
elt: Box<Expression>,
generators: Vec<Comprehension>,
},
Lambda {
args: Vec<Parameter>,
body: Box<Expression>,
},
IfExp {
test: Box<Expression>,
body: Box<Expression>,
orelse: Box<Expression>,
},
}Expand description
表达式
Variants§
Literal(Literal)
字面量
Name(String)
标识符
BinaryOp
二元运算
UnaryOp
一元运算
BoolOp
布尔运算 (and, or)
Compare
比较运算
Call
函数调用
Attribute
属性访问
Subscript
下标访问
List
列表
Fields
§
elts: Vec<Expression>Tuple
元组
Fields
§
elts: Vec<Expression>Dict
字典
Set
集合
Fields
§
elts: Vec<Expression>ListComp
列表推导式
DictComp
字典推导式
SetComp
集合推导式
Lambda
lambda 表达式
IfExp
条件表达式 (三元运算符)
Implementations§
Source§impl Expression
impl Expression
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl<'de> Deserialize<'de> for Expression
impl<'de> Deserialize<'de> for Expression
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
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl Serialize for Expression
impl Serialize for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
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