Skip to main content

Expr

Enum Expr 

Source
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.

Fields

§

Block(Block)

§

If

Fields

§

Match

Fields

§scrutinee: Box<Spanned<Expr>>
§

While

Fields

§

For

Fields

§pattern: Spanned<Pattern>
§

Range

A range expression lo..hi (exclusive) or lo..=hi (inclusive). Phase 1 supports these only as the iterable of a for loop.

Fields

§inclusive: bool
§

Return(Option<Box<Spanned<Expr>>>)

§

Break(Option<Box<Spanned<Expr>>>)

§

Continue

§

Closure

Fields

§params: Vec<Param>
§

Record

Fields

§path: Path
§fields: Vec<FieldInit>
§base: Option<Box<Spanned<Expr>>>

..base spread

§

Binary

Fields

§

Unary

Fields

§op: UnOp
§

Call

Fields

§callee: Box<Spanned<Expr>>
§

Index

Fields

§target: Box<Spanned<Expr>>
§index: Box<Spanned<Expr>>
§

Field

Fields

§target: Box<Spanned<Expr>>
§

Try(Box<Spanned<Expr>>)

expr? — the try / error-propagation operator.

§

Await(Box<Spanned<Expr>>)

expr.await.

§

Cast

expr as Type.

Fields

§

Assign

lhs = rhs, lhs += rhs, etc.

Fields

§

StringInterp(Vec<StringPart>)

A string with interpolated expressions: "Hello, ${name}!".

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Expr

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.