pub enum PyExpr {
Show 13 variants
Name(String),
Attribute(Box<PyExpr>, String),
Subscript {
value: Box<PyExpr>,
slice: Box<PyExpr>,
},
BinOp {
left: Box<PyExpr>,
op: PyOp,
right: Box<PyExpr>,
},
UnaryOp {
op: PyUnaryOp,
operand: Box<PyExpr>,
},
Constant(PyConst),
Tuple(Vec<PyExpr>),
List(Vec<PyExpr>),
Set(Vec<PyExpr>),
Dict(Vec<(Option<PyExpr>, PyExpr)>),
Call {
func: Box<PyExpr>,
args: Vec<PyExpr>,
kwargs: Vec<(String, PyExpr)>,
},
Starred(Box<PyExpr>),
BoolOp {
op: PyBoolOp,
values: Vec<PyExpr>,
},
}Expand description
A parsed Python expression — the subset of ast.expr the py domain
walks (task-3 brief). Negative literals are UnaryOp(USub, Constant),
exactly as in ast; dotted names are Attribute chains.
Variants§
Name(String)
ast.Name.
Attribute(Box<PyExpr>, String)
ast.Attribute: value.attr.
Subscript
ast.Subscript. x[a, b] stores the slice as a Tuple, x[a] as
the bare expression — mirroring ast.
BinOp
ast.BinOp, including BitOr for PEP 604 unions.
UnaryOp
ast.UnaryOp.
Constant(PyConst)
ast.Constant.
Tuple(Vec<PyExpr>)
ast.Tuple.
List(Vec<PyExpr>)
ast.List.
Set(Vec<PyExpr>)
ast.Set (never empty when produced by the parser: {} is a dict).
Dict(Vec<(Option<PyExpr>, PyExpr)>)
ast.Dict; a None key is a ** unpack (PEP 448).
Call
ast.Call. args may contain Starred entries; keywords with
arg=None (f(**kw)) are unrepresentable and parse as Err.
Starred(Box<PyExpr>)
ast.Starred — inside calls, displays and subscript tuples, plus
the two top-level slots exec mode and star_annotation open up
(see the module docs).
BoolOp
ast.BoolOp: a and b, a or b or c. Chains of the same
operator flatten into one node, exactly as CPython’s parser builds
them.
Trait Implementations§
impl Eq for PyExpr
impl StructuralPartialEq for PyExpr
Auto Trait Implementations§
impl Freeze for PyExpr
impl RefUnwindSafe for PyExpr
impl Send for PyExpr
impl Sync for PyExpr
impl Unpin for PyExpr
impl UnsafeUnpin for PyExpr
impl UnwindSafe for PyExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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> ⓘ
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> ⓘ
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