pub enum Expr {
Show 17 variants
Int {
value: BigInt,
span: Span,
},
Float {
value: f64,
span: Span,
},
Str {
value: String,
span: Span,
},
Bool {
value: bool,
span: Span,
},
None {
span: Span,
},
Ident {
name: String,
span: Span,
},
List {
items: Vec<Expr>,
span: Span,
},
Dict {
entries: Vec<(Expr, Expr)>,
span: Span,
},
Binary {
op: BinOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
span: Span,
},
Unary {
op: UnOp,
operand: Box<Expr>,
span: Span,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
kwargs: Vec<(String, Expr)>,
span: Span,
},
Index {
obj: Box<Expr>,
index: Box<Expr>,
span: Span,
},
Slice {
obj: Box<Expr>,
start: Option<Box<Expr>>,
end: Option<Box<Expr>>,
step: Option<Box<Expr>>,
span: Span,
},
Ternary {
cond: Box<Expr>,
then: Box<Expr>,
otherwise: Box<Expr>,
span: Span,
},
Attr {
obj: Box<Expr>,
name: String,
span: Span,
},
SuperCall {
method: String,
args: Vec<Expr>,
span: Span,
},
StrInterp {
parts: Vec<InterpPart>,
span: Span,
},
}Expand description
One expression.
Variants§
Int
Fields
Float
Str
Bool
None
Ident
List
Dict
Binary
Unary
Call
f(a, b, key = c) — positional args, then any keyword arguments as
(name, value) pairs in source order. Keyword arguments are only accepted
where the callee is known at compile time (docs/SYNTAX.md §6).
Index
Slice
obj[start:end:step] — each bound is optional (None means the default
end of that side), matching Python slice semantics.
Fields
Ternary
then if cond else otherwise — only the taken branch is evaluated.
Attr
SuperCall
super.method(args) — call a method inherited from the enclosing class’s
parent, resolved statically. Only valid inside a method of a class that has
a parent (docs/SYNTAX.md §8).
StrInterp
Implementations§
Trait Implementations§
impl StructuralPartialEq for Expr
Auto Trait Implementations§
impl Freeze for Expr
impl RefUnwindSafe for Expr
impl Send for Expr
impl Sync for Expr
impl Unpin for Expr
impl UnsafeUnpin for Expr
impl UnwindSafe for Expr
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