pub enum Expression {
Show 46 variants
Literal {
literal: Literal,
ty: Type,
span: Span,
},
Function {
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: Box<Expression>,
ty: Type,
span: Span,
},
Lambda {
params: Vec<Binding>,
return_annotation: Annotation,
body: Box<Expression>,
ty: Type,
span: Span,
},
Block {
items: Vec<Expression>,
ty: Type,
span: Span,
},
Let {
binding: Box<Binding>,
value: Box<Expression>,
mutable: bool,
mut_span: Option<Span>,
else_block: Option<Box<Expression>>,
else_span: Option<Span>,
typed_pattern: Option<TypedPattern>,
ty: Type,
span: Span,
},
Identifier {
value: EcoString,
ty: Type,
span: Span,
binding_id: Option<BindingId>,
qualified: Option<EcoString>,
},
Call {
expression: Box<Expression>,
args: Vec<Expression>,
type_args: Vec<Annotation>,
ty: Type,
span: Span,
},
If {
condition: Box<Expression>,
consequence: Box<Expression>,
alternative: Box<Expression>,
ty: Type,
span: Span,
},
IfLet {
pattern: Pattern,
scrutinee: Box<Expression>,
consequence: Box<Expression>,
alternative: Box<Expression>,
typed_pattern: Option<TypedPattern>,
else_span: Option<Span>,
ty: Type,
span: Span,
},
Match {
subject: Box<Expression>,
arms: Vec<MatchArm>,
origin: MatchOrigin,
ty: Type,
span: Span,
},
Tuple {
elements: Vec<Expression>,
ty: Type,
span: Span,
},
StructCall {
name: EcoString,
field_assignments: Vec<StructFieldAssignment>,
spread: Box<Option<Expression>>,
ty: Type,
span: Span,
},
DotAccess {
expression: Box<Expression>,
member: EcoString,
ty: Type,
span: Span,
},
Assignment {
target: Box<Expression>,
value: Box<Expression>,
compound_operator: Option<BinaryOperator>,
span: Span,
},
Return {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Propagate {
expression: Box<Expression>,
ty: Type,
span: Span,
},
TryBlock {
items: Vec<Expression>,
ty: Type,
try_keyword_span: Span,
span: Span,
},
RecoverBlock {
items: Vec<Expression>,
ty: Type,
recover_keyword_span: Span,
span: Span,
},
ImplBlock {
annotation: Annotation,
receiver_name: EcoString,
methods: Vec<Expression>,
generics: Vec<Generic>,
ty: Type,
span: Span,
},
Binary {
operator: BinaryOperator,
left: Box<Expression>,
right: Box<Expression>,
ty: Type,
span: Span,
},
Unary {
operator: UnaryOperator,
expression: Box<Expression>,
ty: Type,
span: Span,
},
Paren {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Const {
doc: Option<String>,
identifier: EcoString,
identifier_span: Span,
annotation: Option<Annotation>,
expression: Box<Expression>,
visibility: Visibility,
ty: Type,
span: Span,
},
VariableDeclaration {
doc: Option<String>,
name: EcoString,
name_span: Span,
annotation: Annotation,
visibility: Visibility,
ty: Type,
span: Span,
},
RawGo {
text: String,
},
Loop {
body: Box<Expression>,
ty: Type,
span: Span,
needs_label: bool,
},
While {
condition: Box<Expression>,
body: Box<Expression>,
span: Span,
needs_label: bool,
},
WhileLet {
pattern: Pattern,
scrutinee: Box<Expression>,
body: Box<Expression>,
typed_pattern: Option<TypedPattern>,
span: Span,
needs_label: bool,
},
For {
binding: Box<Binding>,
iterable: Box<Expression>,
body: Box<Expression>,
span: Span,
needs_label: bool,
},
Break {
value: Option<Box<Expression>>,
span: Span,
},
Continue {
span: Span,
},
Enum {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
variants: Vec<EnumVariant>,
visibility: Visibility,
span: Span,
},
ValueEnum {
doc: Option<String>,
name: EcoString,
name_span: Span,
underlying_ty: Option<Annotation>,
variants: Vec<ValueEnumVariant>,
visibility: Visibility,
span: Span,
},
Struct {
doc: Option<String>,
attributes: Vec<Attribute>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
fields: Vec<StructFieldDefinition>,
kind: StructKind,
visibility: Visibility,
span: Span,
},
TypeAlias {
doc: Option<String>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
annotation: Annotation,
ty: Type,
visibility: Visibility,
span: Span,
},
ModuleImport {
name: EcoString,
name_span: Span,
alias: Option<ImportAlias>,
span: Span,
},
Reference {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Interface {
doc: Option<String>,
name: EcoString,
name_span: Span,
generics: Vec<Generic>,
parents: Vec<ParentInterface>,
method_signatures: Vec<Expression>,
visibility: Visibility,
span: Span,
},
IndexedAccess {
expression: Box<Expression>,
index: Box<Expression>,
ty: Type,
span: Span,
},
Task {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Defer {
expression: Box<Expression>,
ty: Type,
span: Span,
},
Select {
arms: Vec<SelectArm>,
ty: Type,
span: Span,
},
Unit {
ty: Type,
span: Span,
},
Range {
start: Option<Box<Expression>>,
end: Option<Box<Expression>>,
inclusive: bool,
ty: Type,
span: Span,
},
Cast {
expression: Box<Expression>,
target_type: Annotation,
ty: Type,
span: Span,
},
NoOp,
}Variants§
Literal
Function
Lambda
Block
Let
Fields
§
value: Box<Expression>§
else_block: Option<Box<Expression>>§
typed_pattern: Option<TypedPattern>Identifier
Fields
Call
If
IfLet
Fields
§
scrutinee: Box<Expression>§
consequence: Box<Expression>§
alternative: Box<Expression>§
typed_pattern: Option<TypedPattern>Match
Tuple
StructCall
DotAccess
Assignment
Return
Propagate
TryBlock
RecoverBlock
ImplBlock
Binary
Unary
Paren
Const
VariableDeclaration
RawGo
Loop
While
WhileLet
For
Break
Continue
Enum
ValueEnum
Struct
TypeAlias
ModuleImport
Reference
Interface
IndexedAccess
Task
Defer
Select
Unit
Range
Cast
NoOp
Implementations§
Source§impl Expression
impl Expression
pub fn is_noop(&self) -> bool
pub fn is_range(&self) -> bool
pub fn is_conditional(&self) -> bool
pub fn is_control_flow(&self) -> bool
pub fn callee_name(&self) -> Option<String>
pub fn to_function_signature(&self) -> FunctionDefinition
pub fn to_function_definition(&self) -> FunctionDefinition
pub fn as_option_constructor(&self) -> Option<Result<(), ()>>
pub fn as_result_constructor(&self) -> Option<Result<(), ()>>
pub fn get_type(&self) -> Type
pub fn get_span(&self) -> Span
pub fn contains_break(&self) -> bool
pub fn diverges(&self) -> Option<DeadCodeCause>
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 unwrap_parens(&self) -> &Expression
pub fn as_dotted_path(&self) -> Option<String>
pub fn root_identifier(&self) -> Option<&str>
pub fn is_empty_collection(&self) -> bool
pub fn is_all_literals(&self) -> bool
pub fn get_var_name(&self) -> Option<String>
pub fn is_function(&self) -> bool
pub fn set_public(self) -> Self
pub fn has_else(&self) -> bool
Trait Implementations§
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§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 Freeze for Expression
impl !RefUnwindSafe for Expression
impl !Send for Expression
impl !Sync for Expression
impl Unpin for Expression
impl UnsafeUnpin for Expression
impl !UnwindSafe for Expression
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