pub enum Expr {
Show 26 variants
Lit(Literal),
Path(Path),
Tuple(Vec<Spanned<Expr>>),
Array(Vec<Spanned<Expr>>),
ArrayRepeat {
init: Box<Spanned<Expr>>,
len: Box<Spanned<Expr>>,
},
Block(Block),
If {
cond: Box<Spanned<Expr>>,
then: Box<Spanned<Block>>,
else_: Option<Box<Spanned<Expr>>>,
},
Match {
scrutinee: Box<Spanned<Expr>>,
arms: Vec<MatchArm>,
},
While {
cond: Box<Spanned<Expr>>,
body: Box<Spanned<Block>>,
},
For {
pattern: Spanned<Pattern>,
iter: Box<Spanned<Expr>>,
body: Box<Spanned<Block>>,
},
Range {
lo: Box<Spanned<Expr>>,
hi: Box<Spanned<Expr>>,
inclusive: bool,
},
Return(Option<Box<Spanned<Expr>>>),
Break(Option<Box<Spanned<Expr>>>),
Continue,
Closure {
params: Vec<Param>,
ret: Option<Spanned<Type>>,
body: Box<Spanned<Expr>>,
},
Record {
path: Path,
fields: Vec<FieldInit>,
base: Option<Box<Spanned<Expr>>>,
},
Binary {
op: BinOp,
lhs: Box<Spanned<Expr>>,
rhs: Box<Spanned<Expr>>,
},
Unary {
op: UnOp,
expr: Box<Spanned<Expr>>,
},
Call {
callee: Box<Spanned<Expr>>,
args: Vec<Spanned<Expr>>,
},
Index {
target: Box<Spanned<Expr>>,
index: Box<Spanned<Expr>>,
},
Field {
target: Box<Spanned<Expr>>,
field: Spanned<String>,
},
Try(Box<Spanned<Expr>>),
Await(Box<Spanned<Expr>>),
Cast {
expr: Box<Spanned<Expr>>,
ty: Spanned<Type>,
},
Assign {
op: AssignOp,
lhs: Box<Spanned<Expr>>,
rhs: Box<Spanned<Expr>>,
},
StringInterp(Vec<StringPart>),
}Expand description
An expression.
Variants§
Lit(Literal)
Path(Path)
Tuple(Vec<Spanned<Expr>>)
Array(Vec<Spanned<Expr>>)
ArrayRepeat
[init; n] — an n-slot array whose every slot is init, with both
init and n evaluated once at runtime.
init is not copied per slot: it is evaluated a single time and that
one value goes into every slot, so for a heap element type all n slots
refer to the same object ([Cell { n: 0 }; 3] is one Cell seen three
times, and a[0].n = 42 shows through a[1] and a[2]). Nova has
reference semantics throughout and no Copy, so there is no per-slot
clone to perform.
Block(Block)
If
Match
While
For
Range
A range expression lo..hi (exclusive) or lo..=hi (inclusive).
Phase 1 supports these only as the iterable of a for loop.
Return(Option<Box<Spanned<Expr>>>)
Break(Option<Box<Spanned<Expr>>>)
Continue
Closure
Record
Binary
Unary
Call
Index
Field
Try(Box<Spanned<Expr>>)
expr? — the try / error-propagation operator.
Await(Box<Spanned<Expr>>)
expr.await.
Cast
expr as Type.
Assign
lhs = rhs, lhs += rhs, etc.
StringInterp(Vec<StringPart>)
A string with interpolated expressions: "Hello, ${name}!".
Trait Implementations§
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