pub enum StatementKind {
Show 41 variants
VariableDeclaration {
name: String,
type_annotation: TypeAnnotation,
value: ExprId,
},
ResolvedVariableDeclaration {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
ConstantDeclaration {
name: String,
type_annotation: TypeAnnotation,
value: ExprId,
},
ResolvedConstantDeclaration {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
Array {
name: String,
type_annotation: TypeAnnotation,
value: Vec<ExprId>,
},
ConstantArray {
name: String,
type_annotation: TypeAnnotation,
value: Vec<ExprId>,
},
ResolvedArray {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
ResolvedConstantArray {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
Map {
name: String,
type_annotation: TypeAnnotation,
entries: Vec<(ExprId, ExprId)>,
},
ConstantMap {
name: String,
type_annotation: TypeAnnotation,
entries: Vec<(ExprId, ExprId)>,
},
ResolvedMap {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
ResolvedConstantMap {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
Set {
name: String,
type_annotation: TypeAnnotation,
items: Vec<ExprId>,
},
ConstantSet {
name: String,
type_annotation: TypeAnnotation,
items: Vec<ExprId>,
},
ResolvedSet {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
ResolvedConstantSet {
name: String,
slot: usize,
type_annotation: TypeAnnotation,
value: ExprId,
},
Expression(ExprId),
While {
condition: ExprId,
body: Vec<Statement>,
},
For {
initializer: Box<Statement>,
condition: ExprId,
increment: ExprId,
body: Vec<Statement>,
},
ResolvedFor {
initializer: Box<Statement>,
condition: ExprId,
increment: ExprId,
body: Vec<Statement>,
},
ForRange {
variable: String,
range: Box<Statement>,
body: Vec<Statement>,
},
ResolvedForRange {
slot: usize,
variable: String,
range: Box<Statement>,
body: Vec<Statement>,
},
ForEach {
variable: String,
iterable: ExprId,
body: Vec<Statement>,
},
ResolvedForEach {
slot: usize,
variable: String,
iterable: ExprId,
body: Vec<Statement>,
},
Range(Vec<i64>),
ConditionalBranch {
condition: Option<ExprId>,
body: Vec<Statement>,
needs_scope: bool,
},
Conditional {
if_branch: Box<Statement>,
else_branch: Option<Box<Statement>>,
},
FunctionDeclaration {
name: String,
params: Vec<Param>,
return_type: TypeAnnotation,
body: Vec<Statement>,
attribute: Option<FunctionAttribute>,
},
ResolvedFunctionDeclaration {
name: String,
slot: usize,
params: Vec<Param>,
return_type: TypeAnnotation,
body: Vec<Statement>,
attribute: Option<FunctionAttribute>,
},
Return(Option<ExprId>),
Break,
Continue,
Import {
names: Vec<String>,
path: Vec<String>,
},
ImportFile {
path: Vec<String>,
},
ResolvedImportFile {
path: Vec<String>,
body: Vec<Statement>,
},
ImportFileNamed {
path: Vec<String>,
names: Vec<String>,
},
DestructureDeclaration {
bindings: Vec<(TypeAnnotation, String)>,
value: ExprId,
},
ResolvedDestructureDeclaration {
bindings: Vec<(TypeAnnotation, String)>,
slots: Vec<usize>,
value: ExprId,
},
Match {
value: ExprId,
arms: Vec<(MatchPattern, Vec<Statement>)>,
},
RecordDeclaration {
name: String,
fields: Vec<(String, TypeAnnotation)>,
},
TagDeclaration {
name: String,
variants: Vec<String>,
},
}Variants§
VariableDeclaration
A mutable variable declaration: dec T name = value.
ResolvedVariableDeclaration
Resolver-annotated mutable variable declaration. slot is the index
in the current environment frame.
ConstantDeclaration
An immutable constant declaration: const T NAME = value.
ResolvedConstantDeclaration
Resolver-annotated constant declaration.
Array
A mutable array declaration with an inline literal: dec array[T] name = [items].
ConstantArray
An immutable array declaration with an inline literal: const array[T] NAME = [items].
ResolvedArray
Resolver-annotated mutable array declaration. value is the
initialiser expression (may be an ExpressionKind::ArrayLiteral).
ResolvedConstantArray
Resolver-annotated constant array declaration.
Map
ConstantMap
ResolvedMap
ResolvedConstantMap
Set
ConstantSet
ResolvedSet
ResolvedConstantSet
Expression(ExprId)
A bare expression used as a statement (e.g. a function call whose return value is discarded, or a newline placeholder).
While
A while condition { body } loop.
For
A C-style for [init, cond, incr] { body } loop.
ResolvedFor
Resolver-annotated C-style for loop.
ForRange
A range-based for x in N..M { body } loop. The range is pre-evaluated
at parse time into a [Range] statement.
ResolvedForRange
Resolver-annotated range-based for loop. slot is the loop variable’s
environment index.
ForEach
A foreach for item in iterable { body } loop over an array expression.
ResolvedForEach
Resolver-annotated foreach loop.
Range(Vec<i64>)
A pre-evaluated integer range produced by the parser for for x in N..M.
ConditionalBranch
A single branch of a conditional: either if condition { body } (condition
is Some) or else { body } (condition is None).
Fields
Conditional
A full if / else-if / else chain.
FunctionDeclaration
A named function declaration.
Fields
return_type: TypeAnnotationattribute: Option<FunctionAttribute>true when the function is marked with !#[entry].
ResolvedFunctionDeclaration
Resolver-annotated function declaration. slot is the function’s
index in the current environment frame.
Return(Option<ExprId>)
A return expr or bare return statement.
Break
Breaks out of the nearest enclosing loop.
Continue
Skips to the next iteration of the nearest enclosing loop.
Import
A stdlib import: get std::ns::fn or get fn from std::ns.
Fields
ImportFile
A file module import: get mymodule or get mymodule::sub.
ResolvedImportFile
A resolved file import - the imported file’s statements are inlined here.
ImportFileNamed
A named file import: get fn, fn from mymodule::sub.
DestructureDeclaration
ResolvedDestructureDeclaration
Match
RecordDeclaration
A record (struct) type declaration: record Name { int a, string b }.
TagDeclaration
A tag (enum) type declaration: tag Name { VariantA, VariantB }.
Trait Implementations§
Source§impl Clone for StatementKind
impl Clone for StatementKind
Source§fn clone(&self) -> StatementKind
fn clone(&self) -> StatementKind
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StatementKind
impl Debug for StatementKind
Source§impl PartialEq for StatementKind
impl PartialEq for StatementKind
impl StructuralPartialEq for StatementKind
Auto Trait Implementations§
impl Freeze for StatementKind
impl RefUnwindSafe for StatementKind
impl !Send for StatementKind
impl !Sync for StatementKind
impl Unpin for StatementKind
impl UnsafeUnpin for StatementKind
impl UnwindSafe for StatementKind
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);