pub enum Expr {
Show 31 variants
Literal {
id: NodeId,
span: Span,
lit: Literal,
},
Identifier {
id: NodeId,
span: Span,
name: Ident,
},
Binary {
id: NodeId,
span: Span,
op: BinOp,
left: Box<Expr>,
right: Box<Expr>,
},
Unary {
id: NodeId,
span: Span,
op: UnaryOp,
operand: Box<Expr>,
},
Assign {
id: NodeId,
span: Span,
op: AssignOp,
target: Box<Expr>,
value: Box<Expr>,
},
Call {
id: NodeId,
span: Span,
callee: Box<Expr>,
args: Vec<Arg>,
type_args: Vec<TypeExpr>,
},
MethodCall {
id: NodeId,
span: Span,
receiver: Box<Expr>,
method: Ident,
type_args: Vec<TypeExpr>,
args: Vec<Arg>,
},
FieldAccess {
id: NodeId,
span: Span,
object: Box<Expr>,
field: Ident,
},
Index {
id: NodeId,
span: Span,
object: Box<Expr>,
index: Box<Expr>,
},
Try {
id: NodeId,
span: Span,
expr: Box<Expr>,
},
Lambda {
id: NodeId,
span: Span,
params: Vec<Param>,
body: Box<Expr>,
},
Pipe {
id: NodeId,
span: Span,
left: Box<Expr>,
right: Box<Expr>,
},
Compose {
id: NodeId,
span: Span,
left: Box<Expr>,
right: Box<Expr>,
},
If {
id: NodeId,
span: Span,
let_pattern: Option<Pattern>,
condition: Box<Expr>,
then_block: Block,
else_block: Option<Box<Expr>>,
},
Match {
id: NodeId,
span: Span,
scrutinee: Box<Expr>,
arms: Vec<MatchArm>,
},
Loop {
id: NodeId,
span: Span,
body: Block,
},
Block {
id: NodeId,
span: Span,
block: Block,
},
RecordConstruct {
id: NodeId,
span: Span,
path: TypePath,
fields: Vec<RecordField>,
spread: Option<Box<RecordSpread>>,
},
ListLiteral {
id: NodeId,
span: Span,
elems: Vec<Expr>,
},
MapLiteral {
id: NodeId,
span: Span,
entries: Vec<(Expr, Expr)>,
},
SetLiteral {
id: NodeId,
span: Span,
elems: Vec<Expr>,
},
TupleLiteral {
id: NodeId,
span: Span,
elems: Vec<Expr>,
},
Range {
id: NodeId,
span: Span,
lo: Box<Expr>,
hi: Box<Expr>,
inclusive: bool,
},
Await {
id: NodeId,
span: Span,
expr: Box<Expr>,
},
Return {
id: NodeId,
span: Span,
value: Option<Box<Expr>>,
},
Break {
id: NodeId,
span: Span,
value: Option<Box<Expr>>,
},
Continue {
id: NodeId,
span: Span,
},
Unreachable {
id: NodeId,
span: Span,
},
Interpolation {
id: NodeId,
span: Span,
parts: Vec<InterpolationPart>,
},
Placeholder {
id: NodeId,
span: Span,
},
Is {
id: NodeId,
span: Span,
expr: Box<Expr>,
type_expr: TypeExpr,
},
}Expand description
An expression node.
Variants§
Literal
A literal value.
Identifier
An identifier reference.
Binary
A binary operation: a + b.
Unary
A unary operation: -x, !flag.
Assign
An assignment expression: x = 5, x += 1.
Call
A function call: f(a, b).
MethodCall
A method call: obj.method(a, b).
Fields
FieldAccess
Field access: obj.field.
Index
Index access: arr[i].
Try
Error propagation: expr?.
Lambda
A lambda: (x) => x * 2.
Pipe
Pipe operator: data |> parse.
Compose
Function composition: parse >> validate.
If
An if / if-let expression.
Fields
Match
A match expression.
Loop
A loop expression: loop { ... break value }.
Block
A block expression: { stmts... }.
RecordConstruct
Record construction: User { id: 1, name, ..defaults }.
ListLiteral
List literal: [1, 2, 3].
MapLiteral
Map literal: {"key": value}.
SetLiteral
Set literal: #{"a", "b"}.
TupleLiteral
Tuple literal: ("hello", 42).
Range
A range: 1..10 (exclusive) or 1..=10 (inclusive).
Await
An await expression: expr.await or await expr.
Return
A return expression.
Break
A break expression, optionally with a value.
Continue
A continue expression.
Unreachable
unreachable — a diverging expression.
Interpolation
A string interpolation: "Hello, ${name}!".
Placeholder
A placeholder _ used in pipe expressions.
Is
A type-check expression: expr is Type[Args].
Stores the full TypeExpr rather than converting to an expression,
so generic arguments (e.g. List[Int]) are preserved.
Implementations§
Trait Implementations§
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> 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,
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§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>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§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);