Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 32 variants Divine { template: StringTemplate, result_ty: Option<TypeExpr>, span: Span, }, Summon { agent: Ident, fields: Vec<FieldInit>, span: Span, }, Await { handle: Box<Expr>, timeout: Option<Box<Expr>>, span: Span, }, Send { handle: Box<Expr>, message: Box<Expr>, span: Span, }, Yield { value: Box<Expr>, span: Span, }, Call { name: Ident, type_args: Vec<TypeExpr>, args: Vec<Expr>, span: Span, }, Apply { callee: Box<Expr>, args: Vec<Expr>, span: Span, }, SelfMethodCall { method: Ident, args: Vec<Expr>, span: Span, }, SelfField { field: Ident, span: Span, }, Binary { op: BinOp, left: Box<Expr>, right: Box<Expr>, span: Span, }, Unary { op: UnaryOp, operand: Box<Expr>, span: Span, }, List { elements: Vec<Expr>, span: Span, }, Literal { value: Literal, span: Span, }, Var { name: Ident, span: Span, }, Paren { inner: Box<Expr>, span: Span, }, StringInterp { template: StringTemplate, span: Span, }, Match { scrutinee: Box<Expr>, arms: Vec<MatchArm>, span: Span, }, RecordConstruct { name: Ident, type_args: Vec<TypeExpr>, fields: Vec<FieldInit>, span: Span, }, FieldAccess { object: Box<Expr>, field: Ident, span: Span, }, Receive { span: Span, }, Try { expr: Box<Expr>, span: Span, }, Catch { expr: Box<Expr>, error_bind: Option<Ident>, recovery: Box<Expr>, span: Span, }, Fail { error: Box<Expr>, span: Span, }, Retry { count: Box<Expr>, delay: Option<Box<Expr>>, on_errors: Option<Vec<Expr>>, body: Box<Expr>, span: Span, }, Trace { message: Box<Expr>, span: Span, }, Closure { params: Vec<ClosureParam>, body: Box<Expr>, span: Span, }, Tuple { elements: Vec<Expr>, span: Span, }, TupleIndex { tuple: Box<Expr>, index: usize, span: Span, }, Map { entries: Vec<MapEntry>, span: Span, }, VariantConstruct { enum_name: Ident, type_args: Vec<TypeExpr>, variant: Ident, payload: Option<Box<Expr>>, span: Span, }, ToolCall { tool: Ident, function: Ident, args: Vec<Expr>, span: Span, }, Reply { message: Box<Expr>, span: Span, },
}
Expand description

An expression.

Variants§

§

Divine

LLM divination: divine("template") or divine("template" -> Type)

Fields

§template: StringTemplate

The prompt template (may contain {ident} interpolations).

§result_ty: Option<TypeExpr>

Optional result type annotation.

§span: Span

Span covering the expression.

§

Summon

Agent summoning: summon AgentName { field: value, ... }

Fields

§agent: Ident

The agent type to spawn.

§fields: Vec<FieldInit>

Initial belief values.

§span: Span

Span covering the expression.

§

Await

Await: await expr or await expr timeout(ms)

Fields

§handle: Box<Expr>

The agent handle to await.

§timeout: Option<Box<Expr>>

Optional timeout in milliseconds.

§span: Span

Span covering the expression.

§

Send

Send message: send(handle, message)

Fields

§handle: Box<Expr>

The agent handle to send to.

§message: Box<Expr>

The message to send.

§span: Span

Span covering the expression.

§

Yield

Yield value: yield(value)

Fields

§value: Box<Expr>

The value to emit to the awaiter.

§span: Span

Span covering the expression.

§

Call

Function call: name(args) or name::<T, U>(args) (turbofish)

Fields

§name: Ident

The function name.

§type_args: Vec<TypeExpr>

Explicit type arguments (turbofish syntax): foo::<Int, String>(...)

§args: Vec<Expr>

The arguments.

§span: Span

Span covering the expression.

§

Apply

Apply expression: call an arbitrary expression as a function. Used for method calls on values: expr.method(args) becomes Apply { callee: FieldAccess { object: expr, field: method }, args }

Fields

§callee: Box<Expr>

The expression being called (typically a FieldAccess for method calls).

§args: Vec<Expr>

The arguments.

§span: Span

Span covering the expression.

§

SelfMethodCall

Method call on self: self.method(args)

Fields

§method: Ident

The method name.

§args: Vec<Expr>

The arguments.

§span: Span

Span covering the expression.

§

SelfField

Self field access: self.field

Fields

§field: Ident

The field (belief) name.

§span: Span

Span covering the expression.

§

Binary

Binary operation: left op right

Fields

§op: BinOp

The operator.

§left: Box<Expr>

The left operand.

§right: Box<Expr>

The right operand.

§span: Span

Span covering the expression.

§

Unary

Unary operation: op operand

Fields

§op: UnaryOp

The operator.

§operand: Box<Expr>

The operand.

§span: Span

Span covering the expression.

§

List

List literal: [a, b, c]

Fields

§elements: Vec<Expr>

The list elements.

§span: Span

Span covering the expression.

§

Literal

Literal value.

Fields

§value: Literal

The literal value.

§span: Span

Span covering the expression.

§

Var

Variable reference.

Fields

§name: Ident

The variable name.

§span: Span

Span covering the expression.

§

Paren

Parenthesized expression: (expr)

Fields

§inner: Box<Expr>

The inner expression.

§span: Span

Span covering the expression (including parens).

§

StringInterp

Interpolated string: "Hello, {name}!"

Fields

§template: StringTemplate

The string template with interpolations.

§span: Span

Span covering the expression.

§

Match

Match expression: match expr { Pattern => expr, ... }

Fields

§scrutinee: Box<Expr>

The scrutinee expression.

§arms: Vec<MatchArm>

The match arms.

§span: Span

Span covering the expression.

§

RecordConstruct

Record construction: Point { x: 1, y: 2 } or Pair::<Int, String> { first: 1, second: "hi" }

Fields

§name: Ident

The record type name.

§type_args: Vec<TypeExpr>

Explicit type arguments (turbofish syntax): Pair::<Int, String> { ... }

§fields: Vec<FieldInit>

Field initializations.

§span: Span

Span covering the expression.

§

FieldAccess

Field access: record.field

Fields

§object: Box<Expr>

The record expression.

§field: Ident

The field name.

§span: Span

Span covering the expression.

§

Receive

Receive message from mailbox: receive()

Fields

§span: Span

Span covering the expression.

§

Try

Try expression: try expr — propagates failure upward.

Fields

§expr: Box<Expr>

The expression that may fail.

§span: Span

Span covering the expression.

§

Catch

Catch expression: expr catch { recovery } or expr catch(e) { recovery }.

Fields

§expr: Box<Expr>

The expression that may fail.

§error_bind: Option<Ident>

The optional error binding (e.g., e in catch(e)).

§recovery: Box<Expr>

The recovery expression.

§span: Span

Span covering the expression.

§

Fail

Fail expression: fail "message" or fail Error { ... }. Type is Never - this expression never returns.

Fields

§error: Box<Expr>

The error value (either a string message or an Error record).

§span: Span

Span covering the expression.

§

Retry

Retry expression: retry(3) { ... } or retry(3, delay: 1000) { ... }

Fields

§count: Box<Expr>

Number of retry attempts (1-10).

§delay: Option<Box<Expr>>

Optional delay between attempts in milliseconds.

§on_errors: Option<Vec<Expr>>

Optional list of error kinds to retry on.

§body: Box<Expr>

The body to retry.

§span: Span

Span covering the expression.

§

Trace

Trace expression: trace("message") for emitting trace events.

Fields

§message: Box<Expr>

The message to trace (must be a string).

§span: Span

Span covering the expression.

§

Closure

Closure expression: |params| body

Fields

§params: Vec<ClosureParam>

The closure parameters.

§body: Box<Expr>

The closure body (single expression).

§span: Span

Span covering the expression.

§

Tuple

Tuple literal: (a, b, c)

Fields

§elements: Vec<Expr>

The tuple elements (at least 2).

§span: Span

Span covering the expression.

§

TupleIndex

Tuple index access: tuple.0

Fields

§tuple: Box<Expr>

The tuple expression.

§index: usize

The index (0-based).

§span: Span

Span covering the expression.

§

Map

Map literal: { key: value, ... } or {}

Fields

§entries: Vec<MapEntry>

The map entries.

§span: Span

Span covering the expression.

§

VariantConstruct

Enum variant construction: MyEnum.Variant or Either::<L, R>.Left(payload)

Fields

§enum_name: Ident

The enum type name.

§type_args: Vec<TypeExpr>

Explicit type arguments (turbofish syntax): Either::<L, R>.Left(...)

§variant: Ident

The variant name.

§payload: Option<Box<Expr>>

The optional payload expression.

§span: Span

Span covering the expression.

§

ToolCall

Tool function call (RFC-0011): Http.get(url)

Fields

§tool: Ident

The tool name.

§function: Ident

The function name.

§args: Vec<Expr>

The arguments.

§span: Span

Span covering the expression.

§

Reply

Reply to current message (Phase 3 session types): reply(message)

Only valid inside on message handlers when the agent follows a protocol.

Fields

§message: Box<Expr>

The message to send back.

§span: Span

Span covering the expression.

Implementations§

Source§

impl Expr

Source

pub fn span(&self) -> &Span

Get the span of this expression.

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Expr

Source§

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

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

impl PartialEq for Expr

Source§

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

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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> Chain<T> for T

Source§

fn len(&self) -> usize

The number of items that this chain link consists of.
Source§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
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> Container<T> for T
where T: Clone,

Source§

type Iter = Once<T>

An iterator over the items within this container, by value.
Source§

fn get_iter(&self) -> <T as Container<T>>::Iter

Iterate over the elements of the container (using internal iteration because GATs are unstable).
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<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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.
Source§

impl<T> OrderedContainer<T> for T
where T: Clone,