Skip to main content

BeamExpr

Enum BeamExpr 

Source
pub enum BeamExpr {
Show 22 variants LitInt(i64), LitFloat(f64), LitAtom(String), LitString(String), Nil, Var(String), Tuple(Vec<BeamExpr>), Cons(Box<BeamExpr>, Box<BeamExpr>), Map(Vec<(BeamExpr, BeamExpr)>), MapUpdate(Box<BeamExpr>, Vec<(BeamExpr, BeamExpr)>), Call { module: Option<String>, func: String, args: Vec<BeamExpr>, }, CallExt { module: Box<BeamExpr>, func: Box<BeamExpr>, args: Vec<BeamExpr>, }, Apply { fun: Box<BeamExpr>, args: Vec<BeamExpr>, }, Case { subject: Box<BeamExpr>, clauses: Vec<BeamClause>, }, Let { var: String, value: Box<BeamExpr>, body: Box<BeamExpr>, }, Letrec { bindings: Vec<(String, Vec<String>, Box<BeamExpr>)>, body: Box<BeamExpr>, }, Fun { params: Vec<String>, body: Box<BeamExpr>, arity: usize, }, Primop { name: String, args: Vec<BeamExpr>, }, Receive { clauses: Vec<BeamClause>, timeout: Option<Box<BeamExpr>>, timeout_action: Option<Box<BeamExpr>>, }, Try { body: Box<BeamExpr>, vars: Vec<String>, handler: Box<BeamExpr>, evars: Vec<String>, catch_body: Box<BeamExpr>, }, Seq(Box<BeamExpr>, Box<BeamExpr>), Binary(Vec<BeamBitSegment>),
}
Expand description

Core Erlang-style expression representation.

These map closely to Core Erlang (the intermediate language used by the Erlang compiler before generating BEAM bytecode).

Variants§

§

LitInt(i64)

Integer literal

§

LitFloat(f64)

Float literal

§

LitAtom(String)

Atom literal (e.g., ok, error, true, false)

§

LitString(String)

String (represented as binary or list of chars in BEAM)

§

Nil

Nil (empty list [])

§

Var(String)

Variable reference

§

Tuple(Vec<BeamExpr>)

Tuple constructor: {Elem1, Elem2, ...}

§

Cons(Box<BeamExpr>, Box<BeamExpr>)

List cons: [Head | Tail]

§

Map(Vec<(BeamExpr, BeamExpr)>)

Map literal: #{Key => Value, ...}

§

MapUpdate(Box<BeamExpr>, Vec<(BeamExpr, BeamExpr)>)

Map update: Map#{Key => Value}

§

Call

Local function call: Module:FuncName(Args...)

Fields

§module: Option<String>
§func: String
§

CallExt

Inter-module call: Module:Function(Args...)

Fields

§module: Box<BeamExpr>
§

Apply

Apply a fun value: Fun(Args...)

Fields

§

Case

Case expression for pattern matching

Fields

§subject: Box<BeamExpr>
§clauses: Vec<BeamClause>
§

Let

Let binding: let Var = Expr in Body

Fields

§value: Box<BeamExpr>
§

Letrec

Letrec (mutually recursive functions)

Fields

§bindings: Vec<(String, Vec<String>, Box<BeamExpr>)>
§

Fun

Fun literal (lambda / closure)

Fields

§params: Vec<String>
§arity: usize
§

Primop

Primitive operation (BIF — Built-In Function)

Fields

§name: String
§

Receive

Receive block with optional timeout

Fields

§clauses: Vec<BeamClause>
§timeout: Option<Box<BeamExpr>>
§timeout_action: Option<Box<BeamExpr>>
§

Try

Try-catch block

Fields

§vars: Vec<String>
§handler: Box<BeamExpr>
§evars: Vec<String>
§catch_body: Box<BeamExpr>
§

Seq(Box<BeamExpr>, Box<BeamExpr>)

Sequence (do-notation style)

§

Binary(Vec<BeamBitSegment>)

Binary construction: <<Segment, ...>>

Trait Implementations§

Source§

impl Clone for BeamExpr

Source§

fn clone(&self) -> BeamExpr

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 BeamExpr

Source§

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

Formats the value using the given formatter. Read more

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.