Enum sway_core::Expression[][src]

pub enum Expression<'sc> {
Show 17 variants Literal { value: Literal<'sc>, span: Span<'sc>, }, FunctionApplication { name: CallPath<'sc>, arguments: Vec<Expression<'sc>>, type_arguments: Vec<(TypeInfo, Span<'sc>)>, span: Span<'sc>, }, LazyOperator { op: LazyOp, lhs: Box<Expression<'sc>>, rhs: Box<Expression<'sc>>, span: Span<'sc>, }, VariableExpression { name: Ident<'sc>, span: Span<'sc>, }, Unit { span: Span<'sc>, }, Array { contents: Vec<Expression<'sc>>, span: Span<'sc>, }, MatchExpression { primary_expression: Box<Expression<'sc>>, branches: Vec<MatchBranch<'sc>>, span: Span<'sc>, }, StructExpression { struct_name: Ident<'sc>, fields: Vec<StructExpressionField<'sc>>, span: Span<'sc>, }, CodeBlock { contents: CodeBlock<'sc>, span: Span<'sc>, }, IfExp { condition: Box<Expression<'sc>>, then: Box<Expression<'sc>>, else: Option<Box<Expression<'sc>>>, span: Span<'sc>, }, AsmExpression { span: Span<'sc>, asm: AsmExpression<'sc>, }, MethodApplication { method_name: MethodName<'sc>, arguments: Vec<Expression<'sc>>, span: Span<'sc>, }, SubfieldExpression { prefix: Box<Expression<'sc>>, span: Span<'sc>, field_to_access: Ident<'sc>, }, DelineatedPath { call_path: CallPath<'sc>, args: Vec<Expression<'sc>>, span: Span<'sc>, type_arguments: Vec<TypeInfo>, }, AbiCast { abi_name: CallPath<'sc>, address: Box<Expression<'sc>>, span: Span<'sc>, }, ArrayIndex { prefix: Box<Expression<'sc>>, index: Box<Expression<'sc>>, span: Span<'sc>, }, DelayedMatchTypeResolution { variant: DelayedResolutionVariant<'sc>, span: Span<'sc>, },
}

Variants

Literal

Fields

value: Literal<'sc>
span: Span<'sc>

FunctionApplication

Fields

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

LazyOperator

Fields

op: LazyOp
lhs: Box<Expression<'sc>>
rhs: Box<Expression<'sc>>
span: Span<'sc>

VariableExpression

Fields

name: Ident<'sc>
span: Span<'sc>

Unit

Fields

span: Span<'sc>

Array

Fields

contents: Vec<Expression<'sc>>
span: Span<'sc>

MatchExpression

Fields

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

StructExpression

Fields

struct_name: Ident<'sc>
fields: Vec<StructExpressionField<'sc>>
span: Span<'sc>

CodeBlock

Fields

contents: CodeBlock<'sc>
span: Span<'sc>

IfExp

Fields

condition: Box<Expression<'sc>>
then: Box<Expression<'sc>>
else: Option<Box<Expression<'sc>>>
span: Span<'sc>

AsmExpression

Fields

span: Span<'sc>
asm: AsmExpression<'sc>

MethodApplication

Fields

method_name: MethodName<'sc>
arguments: Vec<Expression<'sc>>
span: Span<'sc>

SubfieldExpression

Fields

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

A subfield expression is anything of the form:

<ident>.<ident>

DelineatedPath

Fields

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

A [DelineatedPath] 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<'sc>
address: Box<Expression<'sc>>
span: Span<'sc>

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

ArrayIndex

Fields

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

DelayedMatchTypeResolution

Fields

span: Span<'sc>

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)

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

Performs the conversion.

Performs the conversion.

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.