Skip to main content

SwiftExpr

Enum SwiftExpr 

Source
pub enum SwiftExpr {
Show 20 variants SwiftLitExpr(SwiftLit), SwiftVar(String), SwiftCall { callee: Box<SwiftExpr>, args: Vec<(String, SwiftExpr)>, }, SwiftBinOp { op: String, lhs: Box<SwiftExpr>, rhs: Box<SwiftExpr>, }, SwiftMember(Box<SwiftExpr>, String), SwiftSubscript(Box<SwiftExpr>, Box<SwiftExpr>), SwiftUnary(String, Box<SwiftExpr>), SwiftTernary(Box<SwiftExpr>, Box<SwiftExpr>, Box<SwiftExpr>), SwiftClosure { params: Vec<(String, Option<SwiftType>)>, return_type: Option<SwiftType>, body: Vec<SwiftStmt>, }, SwiftSwitchExpr { subject: Box<SwiftExpr>, arms: Vec<(String, SwiftExpr)>, }, SwiftOptionalChain(Box<SwiftExpr>, String), SwiftForceUnwrap(Box<SwiftExpr>), SwiftArrayLit(Vec<SwiftExpr>), SwiftDictLit(Vec<(SwiftExpr, SwiftExpr)>), SwiftTupleLit(Vec<SwiftExpr>), SwiftAs(Box<SwiftExpr>, SwiftType), SwiftTry(Box<SwiftExpr>), SwiftAwait(Box<SwiftExpr>), SwiftSelf, SwiftSuper,
}
Expand description

Swift expression for code generation.

Variants§

§

SwiftLitExpr(SwiftLit)

A literal value: 42, "hello", true, nil

§

SwiftVar(String)

A variable or identifier: x, myVar, MyType

§

SwiftCall

A function/method call: f(a, b)

Fields

§callee: Box<SwiftExpr>

The function or method being called

§args: Vec<(String, SwiftExpr)>

Labeled arguments: (label, expr) — label is empty for unlabeled

§

SwiftBinOp

Binary operator: lhs + rhs, a == b

Fields

§

SwiftMember(Box<SwiftExpr>, String)

Member access: obj.field

§

SwiftSubscript(Box<SwiftExpr>, Box<SwiftExpr>)

Subscript: arr[idx]

§

SwiftUnary(String, Box<SwiftExpr>)

Unary prefix operator: !x, -n

§

SwiftTernary(Box<SwiftExpr>, Box<SwiftExpr>, Box<SwiftExpr>)

Ternary conditional: cond ? then : else

§

SwiftClosure

Closure expression: { params in body }

Fields

§params: Vec<(String, Option<SwiftType>)>

Parameter names with optional types

§return_type: Option<SwiftType>

Return type annotation

§body: Vec<SwiftStmt>

Body statements

§

SwiftSwitchExpr

Switch expression (Swift 5.9+): switch x { case .a: expr }

Fields

§subject: Box<SwiftExpr>

The scrutinee

§arms: Vec<(String, SwiftExpr)>

Arms: (pattern_str, result_expr)

§

SwiftOptionalChain(Box<SwiftExpr>, String)

Optional chaining: obj?.field

§

SwiftForceUnwrap(Box<SwiftExpr>)

Force unwrap: expr!

§

SwiftArrayLit(Vec<SwiftExpr>)

Array literal: [a, b, c]

§

SwiftDictLit(Vec<(SwiftExpr, SwiftExpr)>)

Dictionary literal: [k1: v1, k2: v2]

§

SwiftTupleLit(Vec<SwiftExpr>)

Tuple literal: (a, b)

§

SwiftAs(Box<SwiftExpr>, SwiftType)

Type cast: expr as Type

§

SwiftTry(Box<SwiftExpr>)

Try expression: try expr

§

SwiftAwait(Box<SwiftExpr>)

Await expression: await expr

§

SwiftSelf

Self reference

§

SwiftSuper

Super reference

Trait Implementations§

Source§

impl Clone for SwiftExpr

Source§

fn clone(&self) -> SwiftExpr

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 SwiftExpr

Source§

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

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

impl Display for SwiftExpr

Source§

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

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

impl PartialEq for SwiftExpr

Source§

fn eq(&self, other: &SwiftExpr) -> 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 SwiftExpr

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.