pub enum ExpressionKind {
Show 34 variants
Null,
Integer(i64),
Byte(u8),
Binary {
left: ExprId,
operator: TokenType,
right: ExprId,
},
Unary {
operator: TokenType,
operand: ExprId,
},
Grouping(ExprId),
String(String),
Bool(bool),
Float(f64),
Character(char),
Identifier(String),
ResolvedIdentifier {
name: String,
depth: usize,
slot: usize,
},
ArrayLiteral(Vec<ExprId>),
MapLiteral(Vec<(ExprId, ExprId)>),
SetLiteral(Vec<ExprId>),
Assign {
name: String,
value: ExprId,
},
ResolvedAssign {
name: String,
depth: usize,
slot: usize,
value: ExprId,
},
Call {
path: Vec<String>,
args: Vec<ExprId>,
},
MethodCall {
caller: ExprId,
method: Vec<String>,
args: Vec<ExprId>,
},
Index {
target: ExprId,
index: ExprId,
},
IndexAssign {
target: ExprId,
index: ExprId,
value: ExprId,
},
Lambda {
params: Vec<Param>,
return_type: Option<TypeAnnotation>,
body: Vec<Statement>,
},
ResolvedLambda {
params: Vec<Param>,
return_type: Option<TypeAnnotation>,
body: Vec<Statement>,
capture_depth: usize,
},
CallExpr {
callee: ExprId,
args: Vec<ExprId>,
},
Cast {
value: ExprId,
target_type: TypeAnnotation,
},
TupleLiteral(Vec<ExprId>),
ErrorLiteral(ExprId),
OkLiteral(ExprId),
ErrLiteral(ExprId),
Propagate(ExprId),
StructLiteral {
name: String,
fields: Vec<(String, ExprId)>,
},
FieldAccess {
target: ExprId,
field: String,
},
FieldAssign {
target: ExprId,
field: String,
value: ExprId,
},
EnumVariant {
enum_name: String,
variant: String,
},
}Variants§
Null
The null literal.
Integer(i64)
A 64-bit signed integer literal.
Byte(u8)
A byte literal (u8).
Binary
A binary operation: left operator right.
Unary
A unary prefix operation: operator operand.
Grouping(ExprId)
A parenthesised expression (expr) - preserves grouping in the AST.
String(String)
A string literal.
Bool(bool)
A boolean literal.
Float(f64)
A 64-bit float literal.
Character(char)
A character literal.
Identifier(String)
An unresolved variable or function reference by name.
Replaced by [ResolvedIdentifier] after the resolver pass.
ResolvedIdentifier
A lexically-resolved variable reference.
depth is the number of scopes to walk up; slot is the index within that scope.
ArrayLiteral(Vec<ExprId>)
An array literal [a, b, c].
MapLiteral(Vec<(ExprId, ExprId)>)
SetLiteral(Vec<ExprId>)
Assign
An unresolved variable assignment name = value.
Replaced by [ResolvedAssign] after the resolver pass.
ResolvedAssign
A lexically-resolved variable assignment.
Call
A function call via a module path: std::io::println(args) or f(args).
MethodCall
A method call chain: expr.method(args).
Index
An index access: target[index].
IndexAssign
An index assignment: target[index] = value.
Lambda
An unresolved anonymous function (lambda) expression.
Replaced by [ResolvedLambda] after the resolver pass.
ResolvedLambda
A lexically-resolved lambda. capture_depth is the scope depth at the
point of definition, used to correctly capture the enclosing environment.
Fields
return_type: Option<TypeAnnotation>CallExpr
A call on an arbitrary callee expression, e.g. fns[0](args) or
an immediately-invoked lambda.
Cast
A type cast expression value as type.
Used for non-literal casts; literal casts are constant-folded in the parser.
TupleLiteral(Vec<ExprId>)
ErrorLiteral(ExprId)
OkLiteral(ExprId)
ErrLiteral(ExprId)
Propagate(ExprId)
StructLiteral
A record (struct) literal: Name { field: value, ... }.
FieldAccess
A field access: target.field.
FieldAssign
A field assignment: target.field = value.
EnumVariant
A tag (enum) variant reference: EnumName.Variant.
Trait Implementations§
Source§impl Clone for ExpressionKind
impl Clone for ExpressionKind
Source§fn clone(&self) -> ExpressionKind
fn clone(&self) -> ExpressionKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExpressionKind
impl Debug for ExpressionKind
Source§impl PartialEq for ExpressionKind
impl PartialEq for ExpressionKind
impl StructuralPartialEq for ExpressionKind
Auto Trait Implementations§
impl Freeze for ExpressionKind
impl RefUnwindSafe for ExpressionKind
impl !Send for ExpressionKind
impl !Sync for ExpressionKind
impl Unpin for ExpressionKind
impl UnsafeUnpin for ExpressionKind
impl UnwindSafe for ExpressionKind
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§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>
renamed to 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);