pub enum Expression {
Show 20 variants Literal { value: Literal, span: Span, }, FunctionApplication { name: CallPath, arguments: Vec<Expression>, type_arguments: Vec<(TypeInfo, Span)>, span: Span, }, LazyOperator { op: LazyOp, lhs: Box<Expression>, rhs: Box<Expression>, span: Span, }, VariableExpression { name: Ident, span: Span, }, Tuple { fields: Vec<Expression>, span: Span, }, TupleIndex { prefix: Box<Expression>, index: usize, index_span: Span, span: Span, }, Array { contents: Vec<Expression>, span: Span, }, MatchExpression { primary_expression: Box<Expression>, branches: Vec<MatchBranch>, span: Span, }, StructExpression { struct_name: CallPath, fields: Vec<StructExpressionField>, span: Span, }, CodeBlock { contents: CodeBlock, span: Span, }, IfExp { condition: Box<Expression>, then: Box<Expression>, else: Option<Box<Expression>>, span: Span, }, AsmExpression { span: Span, asm: AsmExpression, }, MethodApplication { method_name: MethodName, contract_call_params: Vec<StructExpressionField>, arguments: Vec<Expression>, span: Span, }, SubfieldExpression { prefix: Box<Expression>, span: Span, field_to_access: Ident, }, DelineatedPath { call_path: CallPath, args: Vec<Expression>, span: Span, type_arguments: Vec<TypeInfo>, }, AbiCast { abi_name: CallPath, address: Box<Expression>, span: Span, }, ArrayIndex { prefix: Box<Expression>, index: Box<Expression>, span: Span, }, DelayedMatchTypeResolution { variant: DelayedResolutionVariant, span: Span, }, SizeOfVal { exp: Box<Expression>, span: Span, }, SizeOfType { type_name: TypeInfo, type_span: Span, span: Span, },
}
Expand description

Represents a parsed, but not yet type checked, Expression.

Variants

Literal

Fields

value: Literal
span: Span

FunctionApplication

Fields

name: CallPath
arguments: Vec<Expression>
type_arguments: Vec<(TypeInfo, Span)>
span: Span

LazyOperator

Fields

op: LazyOp
span: Span

VariableExpression

Fields

name: Ident
span: Span

Tuple

Fields

fields: Vec<Expression>
span: Span

TupleIndex

Fields

prefix: Box<Expression>
index: usize
index_span: Span
span: Span

Array

Fields

contents: Vec<Expression>
span: Span

MatchExpression

Fields

primary_expression: Box<Expression>
branches: Vec<MatchBranch>
span: Span

StructExpression

Fields

struct_name: CallPath
span: Span

CodeBlock

Fields

contents: CodeBlock
span: Span

IfExp

Fields

condition: Box<Expression>
then: Box<Expression>
span: Span

AsmExpression

Fields

span: Span
asm: AsmExpression

MethodApplication

Fields

method_name: MethodName
contract_call_params: Vec<StructExpressionField>
arguments: Vec<Expression>
span: Span

SubfieldExpression

Fields

prefix: Box<Expression>
span: Span
field_to_access: Ident

A subfield expression is anything of the form:

<ident>.<ident>

DelineatedPath

Fields

call_path: CallPath
args: Vec<Expression>
span: Span
type_arguments: Vec<TypeInfo>

A delineated path is anything of the form:

<ident>::<ident>

Where there are n >= 2 idents. These could be either enum variant constructions, or they could be references to some sort of module in the module tree. For example, a reference to a module:

std::ops::add

And, an enum declaration:

enum MyEnum {
  Variant1,
  Variant2
}

MyEnum::Variant1

AbiCast

Fields

abi_name: CallPath
address: Box<Expression>
span: Span

A cast of a hash to an ABI for calling a contract.

ArrayIndex

Fields

prefix: Box<Expression>
index: Box<Expression>
span: Span

DelayedMatchTypeResolution

Fields

span: Span

This variant serves as a stand-in for parsing-level match expression desugaring. Because types cannot be known at parsing-time, a desugared struct or enum gets special cased into this variant. During type checking, this variant is removed as is replaced with the corresponding field or argument access (given that the expression inside of the delayed resolution has the appropriate struct or enum type)

SizeOfVal

Fields

span: Span

SizeOfType

Fields

type_name: TypeInfo
type_span: Span
span: Span

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.