pub enum Expression {
Show 44 variants
Literal {
literal: Literal,
ty: Type,
span: Span,
id: ExpressionId,
},
Function {Show 13 fields
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
params: Vec<Binding>,
return_annotation: Annotation,
return_type: Type,
visibility: Visibility,
body: FunctionBody,
ty: Type,
span: Span,
id: ExpressionId,
},
Lambda {
params: Vec<Binding>,
return_annotation: Annotation,
body: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Block {
items: Vec<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Let {
binding: Box<Binding>,
value: Box<Expression>,
mode: LetMode,
ty: Type,
span: Span,
id: ExpressionId,
},
Identifier {
value: EcoString,
ty: Type,
span: Span,
resolution: IdentifierResolution,
id: ExpressionId,
},
Call {
expression: Box<Expression>,
args: Vec<Expression>,
spread: Option<Box<Expression>>,
type_arguments: CallTypeArguments,
ty: Type,
span: Span,
id: ExpressionId,
},
If {
condition: Box<Expression>,
consequence: Box<Expression>,
alternative: Option<Box<Expression>>,
ty: Type,
span: Span,
id: ExpressionId,
},
IfLet {
pattern: Pattern,
scrutinee: Box<Expression>,
consequence: Box<Expression>,
alternative: IfLetAlternative,
ty: Type,
span: Span,
id: ExpressionId,
},
Match {
subject: Box<Expression>,
arms: Vec<MatchArm>,
ty: Type,
span: Span,
id: ExpressionId,
},
Tuple {
elements: Vec<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
StructCall {
name: EcoString,
field_assignments: Vec<StructFieldAssignment>,
spread: StructSpread,
ty: Type,
span: Span,
id: ExpressionId,
},
DotAccess {
expression: Box<Expression>,
member: EcoString,
ty: Type,
span: Span,
resolution: DotAccessResolution,
id: ExpressionId,
},
Assignment {
target: Box<Expression>,
value: Box<Expression>,
compound_operator: Option<BinaryOperator>,
span: Span,
id: ExpressionId,
},
Return {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Propagate {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
TryBlock {
items: Vec<Expression>,
ty: Type,
try_keyword_span: Span,
span: Span,
id: ExpressionId,
},
RecoverBlock {
items: Vec<Expression>,
ty: Type,
recover_keyword_span: Span,
span: Span,
id: ExpressionId,
},
ImplBlock {
annotation: Annotation,
receiver_name: EcoString,
methods: Vec<Expression>,
generics: Vec<Generic>,
ty: Type,
span: Span,
id: ExpressionId,
},
Binary {
operator: BinaryOperator,
left: Box<Expression>,
right: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Unary {
operator: UnaryOperator,
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Paren {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Const {
binding: Option<BindingId>,
doc: Option<String>,
identifier: EcoString,
identifier_span: Span,
annotation: Option<Annotation>,
expression: ConstInitializer,
visibility: Visibility,
ty: Type,
span: Span,
id: ExpressionId,
},
VariableDeclaration {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
annotation: Annotation,
visibility: Visibility,
ty: Type,
span: Span,
id: ExpressionId,
},
Loop {
body: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
While {
condition: Box<Expression>,
body: Box<Expression>,
span: Span,
id: ExpressionId,
},
WhileLet {
pattern: Pattern,
scrutinee: Box<Expression>,
body: Box<Expression>,
span: Span,
id: ExpressionId,
},
For {
binding: Box<Binding>,
iterable: Box<Expression>,
body: Box<Expression>,
span: Span,
id: ExpressionId,
},
Break {
value: Option<Box<Expression>>,
span: Span,
id: ExpressionId,
},
Continue {
span: Span,
id: ExpressionId,
},
Enum {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
variants: Vec<EnumVariant>,
visibility: Visibility,
span: Span,
id: ExpressionId,
},
Struct {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
fields: StructFields,
visibility: Visibility,
span: Span,
id: ExpressionId,
},
TypeAlias {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
annotation: Annotation,
ty: Type,
visibility: Visibility,
span: Span,
id: ExpressionId,
},
PackageImport {
name: EcoString,
name_span: Span,
alias: Option<ImportAlias>,
span: Span,
id: ExpressionId,
},
Reference {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Interface {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
parents: Vec<ParentInterface>,
method_signatures: Vec<Expression>,
visibility: Visibility,
span: Span,
id: ExpressionId,
},
IndexedAccess {
expression: Box<Expression>,
index: Box<Expression>,
ty: Type,
span: Span,
from_colon_syntax: bool,
id: ExpressionId,
},
Task {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Defer {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Assert {
expression: Box<Expression>,
ty: Type,
span: Span,
id: ExpressionId,
},
Select {
arms: Vec<SelectArm>,
ty: Type,
span: Span,
id: ExpressionId,
},
Unit {
ty: Type,
span: Span,
id: ExpressionId,
},
Range {
start: Option<Box<Expression>>,
end: Option<Box<Expression>>,
inclusive: bool,
ty: Type,
span: Span,
id: ExpressionId,
},
Cast {
expression: Box<Expression>,
target_type: Annotation,
ty: Type,
span: Span,
id: ExpressionId,
},
}Variants§
Literal
Function
Lambda
Block
Let
Identifier
Call
Fields
§
expression: Box<Expression>§
args: Vec<Expression>§
spread: Option<Box<Expression>>§
type_arguments: CallTypeArguments§
id: ExpressionIdIf
Fields
§
condition: Box<Expression>§
consequence: Box<Expression>§
alternative: Option<Box<Expression>>§
id: ExpressionIdIfLet
Fields
§
scrutinee: Box<Expression>§
consequence: Box<Expression>§
alternative: IfLetAlternative§
id: ExpressionIdMatch
Tuple
StructCall
DotAccess
Assignment
Fields
§
target: Box<Expression>§
value: Box<Expression>§
compound_operator: Option<BinaryOperator>§
id: ExpressionIdReturn
Propagate
TryBlock
RecoverBlock
ImplBlock
Binary
Unary
Paren
Const
Fields
§
annotation: Option<Annotation>§
expression: ConstInitializer§
visibility: Visibility§
id: ExpressionIdVariableDeclaration
Loop
While
WhileLet
For
Break
Continue
Enum
Struct
TypeAlias
PackageImport
Reference
Interface
Fields
§
parents: Vec<ParentInterface>§
method_signatures: Vec<Expression>§
visibility: Visibility§
id: ExpressionIdIndexedAccess
Task
Defer
Assert
Select
Unit
Range
Cast
Implementations§
Source§impl Expression
impl Expression
pub fn imaginary_coefficient(&self) -> Option<f64>
Sourcepub fn id(&self) -> ExpressionId
pub fn id(&self) -> ExpressionId
The occurrence that this node is, which names its checked records.
pub fn is_range(&self) -> bool
pub fn is_conditional(&self) -> bool
pub fn is_control_flow(&self) -> bool
pub fn is_temp_producing(&self) -> bool
pub fn function_definition_view(&self) -> FunctionDefinitionView<'_>
pub fn get_type(&self) -> Type
pub fn value_type(&self) -> Option<Type>
pub fn type_ref(&self) -> Option<&Type>
pub fn get_span(&self) -> Span
pub fn set_span(&mut self, new_span: Span)
pub fn contains_break(&self) -> bool
pub fn diverges(&self) -> Option<DeadCodeCause>
pub fn evaluation_children(&self) -> Vec<&Expression>
pub fn propagation_children(&self) -> Vec<&Expression>
Sourcepub fn children(&self) -> Vec<&Expression>
pub fn children(&self) -> Vec<&Expression>
Returns references to all direct child expressions.
This is the single source of truth for expression tree recursion. Use this instead of writing per-variant match arms when you need to walk an expression tree.
pub fn for_each_child<'a>(&'a self, f: impl FnMut(&'a Expression))
pub fn introduced_patterns<'a>( &'a self, f: impl FnMut(&'a Pattern, PatternSite), )
pub fn for_each_child_mut<'a>(&'a mut self, f: impl FnMut(&'a mut Expression))
pub fn strip_wrappers(&mut self)
pub fn contains_wrapper(&self) -> bool
pub fn reads_reference_once(&self) -> bool
pub fn is_reference_receiver(&self) -> bool
pub fn is_fresh_reference(&self) -> bool
pub fn unwrap_parens(&self) -> &Expression
pub fn unwrap_value_wrappers(&self) -> &Expression
pub fn is_piped_call(&self) -> bool
pub fn binding_id(&self) -> Option<BindingId>
pub fn as_integer(&self) -> Option<u64>
Sourcepub fn deref_inner(&self) -> Option<&Expression>
pub fn deref_inner(&self) -> Option<&Expression>
Inner expression of an explicit x.* deref, or None for anything else.
pub fn as_dotted_path(&self) -> Option<String>
pub fn root_identifier(&self) -> Option<&str>
pub fn root_binding_id(&self) -> Option<BindingId>
pub fn is_empty_collection(&self) -> bool
pub fn is_all_literals(&self) -> bool
pub fn get_var_name(&self) -> Option<String>
pub fn has_else(&self) -> bool
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§impl Debug for Expression
impl Debug for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Forget for Expression
impl Freeze for Expressionwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<FormatStringPart>: Freeze,
PhantomData<Expression>: Freeze,
*const ArcInner<Box<[Type]>> is !null: Freeze,
PhantomData<ArcInner<Box<[Type]>>>: Freeze,
*const ArcInner<FunctionType> is !null: Freeze,
PhantomData<ArcInner<FunctionType>>: Freeze,
PhantomData<Type>: Freeze,
*const Type is !null: Freeze,
*const ArcInner<Spelling> is !null: Freeze,
PhantomData<ArcInner<Spelling>>: Freeze,
PhantomData<Attribute>: Freeze,
PhantomData<Generic>: Freeze,
PhantomData<Binding>: Freeze,
PhantomData<Annotation>: Freeze,
*const Annotation is !null: Freeze,
*const Expression is !null: Freeze,
*const Binding is !null: Freeze,
PhantomData<(EcoString, Type)>: Freeze,
PhantomData<ResolvedCallTypeArgument>: Freeze,
PhantomData<Pattern>: Freeze,
PhantomData<StructFieldPattern>: Freeze,
*const Pattern is !null: Freeze,
PhantomData<MatchArm>: Freeze,
PhantomData<StructFieldAssignment>: Freeze,
PhantomData<EnumVariant>: Freeze,
PhantomData<StructFieldDefinition>: Freeze,
PhantomData<ParentInterface>: Freeze,
PhantomData<SelectArm>: Freeze,
impl Move for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expressionwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<FormatStringPart>: UnsafeUnpin,
PhantomData<Expression>: UnsafeUnpin,
*const ArcInner<Box<[Type]>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Box<[Type]>>>: UnsafeUnpin,
*const ArcInner<FunctionType> is !null: UnsafeUnpin,
PhantomData<ArcInner<FunctionType>>: UnsafeUnpin,
PhantomData<Type>: UnsafeUnpin,
*const Type is !null: UnsafeUnpin,
*const ArcInner<Spelling> is !null: UnsafeUnpin,
PhantomData<ArcInner<Spelling>>: UnsafeUnpin,
PhantomData<Attribute>: UnsafeUnpin,
PhantomData<Generic>: UnsafeUnpin,
PhantomData<Binding>: UnsafeUnpin,
PhantomData<Annotation>: UnsafeUnpin,
*const Annotation is !null: UnsafeUnpin,
*const Expression is !null: UnsafeUnpin,
*const Binding is !null: UnsafeUnpin,
PhantomData<(EcoString, Type)>: UnsafeUnpin,
PhantomData<ResolvedCallTypeArgument>: UnsafeUnpin,
PhantomData<Pattern>: UnsafeUnpin,
PhantomData<StructFieldPattern>: UnsafeUnpin,
*const Pattern is !null: UnsafeUnpin,
PhantomData<MatchArm>: UnsafeUnpin,
PhantomData<StructFieldAssignment>: UnsafeUnpin,
PhantomData<EnumVariant>: UnsafeUnpin,
PhantomData<StructFieldDefinition>: UnsafeUnpin,
PhantomData<ParentInterface>: UnsafeUnpin,
PhantomData<SelectArm>: UnsafeUnpin,
impl UnwindSafe for Expressionwhere
RawVecInner: UnwindSafe,
BoxRaw<Expression>: UnwindSafe,
Arc<Box<[Type]>>: UnwindSafe,
NonNull<u8>: UnwindSafe,
Arc<FunctionType>: UnwindSafe,
BoxRaw<Type>: UnwindSafe,
Arc<Spelling>: UnwindSafe,
BoxRaw<Annotation>: UnwindSafe,
BoxRaw<Pattern>: UnwindSafe,
BoxRaw<Binding>: UnwindSafe,
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