Enum Expr
pub enum Expr {
Show 39 variants
Int(IntLit),
Float(FloatLit),
String(StringLit),
Char(CharLit),
Bool(BoolLit),
Unit(UnitLit),
Ident(Ident),
Binary(BinaryExpr),
Unary(UnaryExpr),
Paren(ParenExpr),
Block(BlockExpr),
If(IfExpr),
Match(MatchExpr),
While(WhileExpr),
For(ForExpr),
Loop(LoopExpr),
Call(CallExpr),
Break(BreakExpr),
Continue(ContinueExpr),
Return(ReturnExpr),
StructLit(StructLitExpr),
Field(FieldExpr),
MethodCall(MethodCallExpr),
IntrinsicCall(IntrinsicCallExpr),
ArrayLit(ArrayLitExpr),
Index(IndexExpr),
Path(PathExpr),
EnumStructLit(EnumStructLitExpr),
AssocFnCall(AssocFnCallExpr),
SelfExpr(SelfExpr),
Comptime(ComptimeBlockExpr),
ComptimeUnrollFor(ComptimeUnrollForExpr),
Checked(CheckedBlockExpr),
TypeLit(TypeLitExpr),
Tuple(TupleExpr),
TupleIndex(TupleIndexExpr),
Range(RangeExpr),
AnonFn(AnonFnExpr),
Error(Span),
}Expand description
An expression.
Variants§
Int(IntLit)
Integer literal
Float(FloatLit)
Floating-point literal
String(StringLit)
String literal
Char(CharLit)
Character literal — Unicode scalar value (ADR-0071)
Bool(BoolLit)
Boolean literal
Unit(UnitLit)
Unit literal (explicit () or implicit unit for blocks without final expression)
Ident(Ident)
Identifier reference (variable)
Binary(BinaryExpr)
Binary operation (e.g., a + b)
Unary(UnaryExpr)
Unary operation (e.g., -x)
Paren(ParenExpr)
Parenthesized expression (e.g., (a + b))
Block(BlockExpr)
Block with statements and final expression
If(IfExpr)
If expression (e.g., if cond { a } else { b })
Match(MatchExpr)
Match expression (e.g., match x { 1 => a, _ => b })
While(WhileExpr)
While expression (e.g., while cond { body })
For(ForExpr)
For-in expression (e.g., for x in arr { body })
Loop(LoopExpr)
Loop expression - infinite loop (e.g., loop { body })
Call(CallExpr)
Function call (e.g., foo(1, 2))
Break(BreakExpr)
Break statement (exits the innermost loop)
Continue(ContinueExpr)
Continue statement (skips to the next iteration of the innermost loop)
Return(ReturnExpr)
Return statement (returns a value from the current function)
StructLit(StructLitExpr)
Struct literal (e.g., Point { x: 1, y: 2 })
Field(FieldExpr)
Field access (e.g., point.x)
MethodCall(MethodCallExpr)
Method call (e.g., point.distance())
IntrinsicCall(IntrinsicCallExpr)
Intrinsic call (e.g., @dbg(42))
ArrayLit(ArrayLitExpr)
Array literal (e.g., [1, 2, 3])
Index(IndexExpr)
Array indexing (e.g., arr[0])
Path(PathExpr)
Path expression (e.g., Color::Red)
EnumStructLit(EnumStructLitExpr)
Enum struct variant literal (e.g., Shape::Circle { radius: 5 })
AssocFnCall(AssocFnCallExpr)
Associated function call (e.g., Point::origin())
SelfExpr(SelfExpr)
Self expression (e.g., self in method bodies)
Comptime(ComptimeBlockExpr)
Comptime block expression (e.g., comptime { 1 + 2 })
ComptimeUnrollFor(ComptimeUnrollForExpr)
Comptime unroll for expression (e.g., comptime_unroll for field in info.fields { ... })
Checked(CheckedBlockExpr)
Checked block expression (e.g., checked { @ptr_read(p) })
TypeLit(TypeLitExpr)
Type literal expression (e.g., i32 used as a value in generic function calls)
Tuple(TupleExpr)
Tuple literal expression (e.g., (1, true), (42,)) (ADR-0048)
TupleIndex(TupleIndexExpr)
Tuple index expression (e.g., t.0, t.1) (ADR-0048)
Range(RangeExpr)
Range expression for slice subscripts (ADR-0064): .., a.., ..b,
a..b, a..b :s. Only legal as the index of an IndexExpr; sema
rejects bare ranges in other positions.
AnonFn(AnonFnExpr)
Anonymous function expression (e.g., fn(x: i32) -> i32 { x + 1 }) (ADR-0055)
Error(Span)
Error node for recovered parse errors. Used by error recovery to continue parsing after a syntax error.
Implementations§
Trait Implementations§
§impl<'de> Deserialize<'de> for Expr
impl<'de> Deserialize<'de> for Expr
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Expr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Expr, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl RemapSpurs for Expr
impl RemapSpurs for Expr
fn remap_spurs(&mut self, table: &[Spur])
§impl Serialize for Expr
impl Serialize for Expr
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Expr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].