pub enum ExprKind {
Show 31 variants
IntLit(i64),
FloatLit {
value: f64,
lexeme: String,
},
DurationLit {
value: i64,
unit: DurationUnit,
millis: i64,
},
StrLit(String),
InterpStr(Vec<InterpPart>),
BoolLit(bool),
Ident(Ident),
Call {
name: Ident,
type_args: Vec<TypeRef>,
args: Vec<Expr>,
},
Lambda(LambdaExpr),
BinOp(BinOp, Box<Expr>, Box<Expr>),
UnaryOp(UnaryOp, Box<Expr>),
Paren(Box<Expr>),
Block(Block),
If {
cond: Box<Expr>,
then_block: Box<Block>,
else_block: Box<Block>,
},
Ok(Box<Expr>),
Err(Box<Expr>),
Question(Box<Expr>),
ConstructorCall {
type_name: Ident,
method: Ident,
args: Vec<Expr>,
},
RecordConstruction {
type_name: Ident,
fields: Vec<FieldInit>,
},
FieldAccess {
receiver: Box<Expr>,
field: Ident,
},
MethodCall {
receiver: Box<Expr>,
method: Ident,
type_args: Vec<TypeRef>,
args: Vec<Expr>,
},
Match {
discriminant: Box<Expr>,
arms: Vec<MatchArm>,
},
Is {
value: Box<Expr>,
pattern: Pattern,
},
Some(Box<Expr>),
None,
UnitLit,
RecordSpread {
type_name: Option<Ident>,
base: Box<Expr>,
overrides: Vec<FieldInit>,
},
EffectPure(Box<Expr>),
Expect(Box<Expr>),
Val {
type_ref: TypeRef,
args: Vec<Expr>,
},
ListLit(Vec<Expr>),
}Variants§
IntLit(i64)
FloatLit
A float literal (v0.21). The lexeme is kept alongside the parsed
value so emission and formatting are byte-stable (1e10 must not
normalise to 10000000000).
DurationLit
A duration literal <int>.<unit> (v0.86, ADR 0112): 5.minutes,
30.days. The parser recognises the IntLit . <unit> shape and records
the magnitude, the unit, and the resolved milliseconds (the value the
emitter lowers to). Typed Duration.
Fields
unit: DurationUnitThe unit name (minutes), one of the closed set.
StrLit(String)
InterpStr(Vec<InterpPart>)
An interpolated string "… \(expr) …" (v0.43, ADR 0075). Chunks and
holes alternate. A plain "…" with no holes stays ExprKind::StrLit,
so existing code and the emitter/formatter fast-path are untouched.
BoolLit(bool)
Ident(Ident)
Call
Fields
Lambda(LambdaExpr)
A lambda (v0.20a). See LambdaExpr.
BinOp(BinOp, Box<Expr>, Box<Expr>)
UnaryOp(UnaryOp, Box<Expr>)
Paren(Box<Expr>)
Block(Block)
{ stmts; expr } — block expression (v0.1).
If
if cond { then } else { else } (v0.1).
Ok(Box<Expr>)
Ok(value) — Result success constructor (v0.1).
Err(Box<Expr>)
Err(error) — Result failure constructor (v0.1).
Question(Box<Expr>)
expr? — propagation operator (v0.1).
ConstructorCall
TypeName.method(args) — qualified static call on a type
(v0.1: only refined-type of; v0.2: any static method or variant
constructor for sum types). The resolver decides which.
RecordConstruction
TypeName { field: value, ... } — record construction (v0.2).
FieldAccess
receiver.field — field access on a record value (v0.2). v0.3 adds
.raw on opaque types within the defining commons.
MethodCall
receiver.method(args) — instance method call (v0.2). The
resolver determines the receiver’s type and looks up the method.
Fields
Match
match disc { arm+ } — pattern matching (v0.2).
Is
expr is pattern — pattern test, returns Bool (v0.2).
Some(Box<Expr>)
Some(value) — Option Some constructor (v0.2).
None
None — Option None constructor (v0.2).
UnitLit
() — unit literal (v0.5).
RecordSpread
TypeName { ...base, field: value, ... } or { ...base, ... } —
record spread expression (v0.5).
Fields
EffectPure(Box<Expr>)
Effect.pure(value) — wrap a synchronous value into Effect[T]
(v0.5). Recognised in the parser as a special-form.
Expect(Box<Expr>)
expect expr — expectation as an expression of type () (v0.9.1;
renamed from assert in v0.112). Valid only inside test bodies. Evaluates
expr (must be Bool); if false, the surrounding test case fails.
Val
Val[T], Val[T](args) — test-context value construction (v0.9.4).
args is empty for the bare form and holds the pin arguments for
Val[T](...). The record-override form Val[T] { ... } is not yet
parsed. Valid only inside test bodies; has type T.
ListLit(Vec<Expr>)
[a, b, c] — list literal (v0.20b). An empty [] requires an
expected type (bynk.types.uninferable_element_type).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExprKind
impl RefUnwindSafe for ExprKind
impl Send for ExprKind
impl Sync for ExprKind
impl Unpin for ExprKind
impl UnsafeUnpin for ExprKind
impl UnwindSafe for ExprKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);