Skip to main content

Expression

Enum Expression 

Source
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

Fields

§literal: Literal
§ty: Type
§span: Span
§

Function

Fields

§attributes: Vec<Attribute>
§name_span: Span
§generics: Vec<Generic>
§params: Vec<Binding>
§return_annotation: Annotation
§return_type: Type
§visibility: Visibility
§ty: Type
§span: Span
§

Lambda

Fields

§params: Vec<Binding>
§return_annotation: Annotation
§ty: Type
§span: Span
§

Block

Fields

§ty: Type
§span: Span
§

Let

Fields

§binding: Box<Binding>
§mutable: bool
§mut_span: Option<Span>
§else_block: Option<Box<Expression>>
§else_span: Option<Span>
§typed_pattern: Option<TypedPattern>
§ty: Type
§span: Span
§

Identifier

Fields

§ty: Type
§span: Span
§binding_id: Option<BindingId>
§qualified: Option<EcoString>
§

Call

Fields

§expression: Box<Expression>
§type_args: Vec<Annotation>
§ty: Type
§span: Span
§

If

Fields

§condition: Box<Expression>
§consequence: Box<Expression>
§alternative: Box<Expression>
§ty: Type
§span: Span
§

IfLet

Fields

§pattern: Pattern
§scrutinee: Box<Expression>
§consequence: Box<Expression>
§alternative: Box<Expression>
§typed_pattern: Option<TypedPattern>
§else_span: Option<Span>
§ty: Type
§span: Span
§

Match

Fields

§subject: Box<Expression>
§ty: Type
§span: Span
§

Tuple

Fields

§elements: Vec<Expression>
§ty: Type
§span: Span
§

StructCall

Fields

§field_assignments: Vec<StructFieldAssignment>
§ty: Type
§span: Span
§

DotAccess

Fields

§expression: Box<Expression>
§member: EcoString
§ty: Type
§span: Span
§

Assignment

Fields

§target: Box<Expression>
§compound_operator: Option<BinaryOperator>
§span: Span
§

Return

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Propagate

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

TryBlock

Fields

§ty: Type
§try_keyword_span: Span
§span: Span
§

RecoverBlock

Fields

§ty: Type
§recover_keyword_span: Span
§span: Span
§

ImplBlock

Fields

§annotation: Annotation
§receiver_name: EcoString
§methods: Vec<Expression>
§generics: Vec<Generic>
§ty: Type
§span: Span
§

Binary

Fields

§ty: Type
§span: Span
§

Unary

Fields

§operator: UnaryOperator
§expression: Box<Expression>
§ty: Type
§span: Span
§

Paren

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Const

Fields

§identifier: EcoString
§identifier_span: Span
§annotation: Option<Annotation>
§expression: Box<Expression>
§visibility: Visibility
§ty: Type
§span: Span
§

VariableDeclaration

Fields

§name_span: Span
§annotation: Annotation
§visibility: Visibility
§ty: Type
§span: Span
§

RawGo

Fields

§text: String
§

Loop

Fields

§ty: Type
§span: Span
§needs_label: bool
§

While

Fields

§condition: Box<Expression>
§span: Span
§needs_label: bool
§

WhileLet

Fields

§pattern: Pattern
§scrutinee: Box<Expression>
§typed_pattern: Option<TypedPattern>
§span: Span
§needs_label: bool
§

For

Fields

§binding: Box<Binding>
§iterable: Box<Expression>
§span: Span
§needs_label: bool
§

Break

Fields

§span: Span
§

Continue

Fields

§span: Span
§

Enum

Fields

§attributes: Vec<Attribute>
§name_span: Span
§generics: Vec<Generic>
§variants: Vec<EnumVariant>
§visibility: Visibility
§span: Span
§

ValueEnum

Fields

§name_span: Span
§underlying_ty: Option<Annotation>
§visibility: Visibility
§span: Span
§

Struct

Fields

§attributes: Vec<Attribute>
§name_span: Span
§generics: Vec<Generic>
§visibility: Visibility
§span: Span
§

TypeAlias

Fields

§name_span: Span
§generics: Vec<Generic>
§annotation: Annotation
§ty: Type
§visibility: Visibility
§span: Span
§

ModuleImport

Fields

§name_span: Span
§span: Span
§

Reference

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Interface

Fields

§name_span: Span
§generics: Vec<Generic>
§method_signatures: Vec<Expression>
§visibility: Visibility
§span: Span
§

IndexedAccess

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Task

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Defer

Fields

§expression: Box<Expression>
§ty: Type
§span: Span
§

Select

Fields

§ty: Type
§span: Span
§

Unit

Fields

§ty: Type
§span: Span
§

Range

Fields

§inclusive: bool
§ty: Type
§span: Span
§

Cast

Fields

§expression: Box<Expression>
§target_type: Annotation
§ty: Type
§span: Span
§

NoOp

Implementations§

Source§

impl Expression

Source

pub fn is_noop(&self) -> bool

Source

pub fn is_range(&self) -> bool

Source

pub fn is_conditional(&self) -> bool

Source

pub fn is_control_flow(&self) -> bool

Source

pub fn callee_name(&self) -> Option<String>

Source

pub fn to_function_signature(&self) -> FunctionDefinition

Source

pub fn to_function_definition(&self) -> FunctionDefinition

Source

pub fn as_option_constructor(&self) -> Option<Result<(), ()>>

Source

pub fn as_result_constructor(&self) -> Option<Result<(), ()>>

Source

pub fn get_type(&self) -> Type

Source

pub fn get_span(&self) -> Span

Source

pub fn contains_break(&self) -> bool

Source

pub fn diverges(&self) -> Option<DeadCodeCause>

Source

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.

Source

pub fn unwrap_parens(&self) -> &Expression

Source

pub fn as_dotted_path(&self) -> Option<String>

Source

pub fn root_identifier(&self) -> Option<&str>

Source

pub fn is_empty_collection(&self) -> bool

Source

pub fn is_all_literals(&self) -> bool

Source

pub fn get_var_name(&self) -> Option<String>

Source

pub fn is_function(&self) -> bool

Source

pub fn set_public(self) -> Self

Source

pub fn has_else(&self) -> bool

Trait Implementations§

Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Expression

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Expression

Source§

fn eq(&self, other: &Expression) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Expression

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.