Skip to main content

NodeKind

Enum NodeKind 

Source
#[non_exhaustive]
pub enum NodeKind {
Show 74 variants Module { path: Option<ModulePath>, annotations: Vec<Annotation>, imports: Vec<AIRNode>, items: Vec<AIRNode>, }, ImportDecl { path: ModulePath, items: ImportItems, }, FnDecl { annotations: Vec<Annotation>, visibility: Visibility, is_async: bool, name: Ident, generic_params: Vec<GenericParam>, params: Vec<AIRNode>, return_type: Option<Box<AIRNode>>, effect_clause: Vec<TypePath>, where_clause: Vec<TypeConstraint>, body: Box<AIRNode>, }, RecordDecl { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, generic_params: Vec<GenericParam>, fields: Vec<RecordDeclField>, }, EnumDecl { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, generic_params: Vec<GenericParam>, variants: Vec<AIRNode>, }, EnumVariant { name: Ident, payload: EnumVariantPayload, }, ClassDecl { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, generic_params: Vec<GenericParam>, base: Option<TypePath>, traits: Vec<TypePath>, fields: Vec<RecordDeclField>, methods: Vec<AIRNode>, }, TraitDecl { annotations: Vec<Annotation>, visibility: Visibility, is_platform: bool, name: Ident, generic_params: Vec<GenericParam>, associated_types: Vec<AssociatedType>, methods: Vec<AIRNode>, }, ImplBlock { annotations: Vec<Annotation>, generic_params: Vec<GenericParam>, trait_path: Option<TypePath>, target: Box<AIRNode>, where_clause: Vec<TypeConstraint>, methods: Vec<AIRNode>, }, EffectDecl { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, generic_params: Vec<GenericParam>, components: Vec<TypePath>, operations: Vec<AIRNode>, }, TypeAlias { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, generic_params: Vec<GenericParam>, ty: Box<AIRNode>, where_clause: Vec<TypeConstraint>, }, ConstDecl { annotations: Vec<Annotation>, visibility: Visibility, name: Ident, ty: Box<AIRNode>, value: Box<AIRNode>, }, ModuleHandle { effect: TypePath, handler: Box<AIRNode>, }, PropertyTest { name: String, bindings: Vec<PropertyBinding>, body: Box<AIRNode>, }, Param { pattern: Box<AIRNode>, ty: Option<Box<AIRNode>>, default: Option<Box<AIRNode>>, }, TypeNamed { path: TypePath, args: Vec<AIRNode>, }, TypeTuple { elems: Vec<AIRNode>, }, TypeFunction { params: Vec<AIRNode>, ret: Box<AIRNode>, effects: Vec<TypePath>, }, TypeOptional { inner: Box<AIRNode>, }, TypeSelf, Literal { lit: Literal, }, Identifier { name: Ident, }, BinaryOp { op: BinOp, left: Box<AIRNode>, right: Box<AIRNode>, }, UnaryOp { op: UnaryOp, operand: Box<AIRNode>, }, Assign { op: AssignOp, target: Box<AIRNode>, value: Box<AIRNode>, }, Call { callee: Box<AIRNode>, args: Vec<AirArg>, type_args: Vec<AIRNode>, }, MethodCall { receiver: Box<AIRNode>, method: Ident, type_args: Vec<AIRNode>, args: Vec<AirArg>, }, FieldAccess { object: Box<AIRNode>, field: Ident, }, Index { object: Box<AIRNode>, index: Box<AIRNode>, }, Propagate { expr: Box<AIRNode>, }, Lambda { params: Vec<AIRNode>, body: Box<AIRNode>, }, Pipe { left: Box<AIRNode>, right: Box<AIRNode>, }, Compose { left: Box<AIRNode>, right: Box<AIRNode>, }, Await { expr: Box<AIRNode>, }, Range { lo: Box<AIRNode>, hi: Box<AIRNode>, inclusive: bool, }, RecordConstruct { path: TypePath, fields: Vec<AirRecordField>, spread: Option<Box<AIRNode>>, }, ListLiteral { elems: Vec<AIRNode>, }, MapLiteral { entries: Vec<AirMapEntry>, }, SetLiteral { elems: Vec<AIRNode>, }, TupleLiteral { elems: Vec<AIRNode>, }, Interpolation { parts: Vec<AirInterpolationPart>, }, Placeholder, Unreachable, ResultConstruct { variant: ResultVariant, value: Option<Box<AIRNode>>, }, If { let_pattern: Option<Box<AIRNode>>, condition: Box<AIRNode>, then_block: Box<AIRNode>, else_block: Option<Box<AIRNode>>, }, Guard { let_pattern: Option<Box<AIRNode>>, condition: Box<AIRNode>, else_block: Box<AIRNode>, }, Match { scrutinee: Box<AIRNode>, arms: Vec<AIRNode>, }, MatchArm { pattern: Box<AIRNode>, guard: Option<Box<AIRNode>>, body: Box<AIRNode>, }, For { pattern: Box<AIRNode>, iterable: Box<AIRNode>, body: Box<AIRNode>, }, While { condition: Box<AIRNode>, body: Box<AIRNode>, }, Loop { body: Box<AIRNode>, }, Block { stmts: Vec<AIRNode>, tail: Option<Box<AIRNode>>, }, Return { value: Option<Box<AIRNode>>, }, Break { value: Option<Box<AIRNode>>, }, Continue, LetBinding { is_mut: bool, pattern: Box<AIRNode>, ty: Option<Box<AIRNode>>, value: Box<AIRNode>, }, Move { expr: Box<AIRNode>, }, Borrow { expr: Box<AIRNode>, }, MutableBorrow { expr: Box<AIRNode>, }, EffectOp { effect: TypePath, operation: Ident, args: Vec<AirArg>, }, HandlingBlock { handlers: Vec<AirHandlerPair>, body: Box<AIRNode>, }, EffectRef { path: TypePath, }, WildcardPat, BindPat { name: Ident, is_mut: bool, }, LiteralPat { lit: Literal, }, ConstructorPat { path: TypePath, fields: Vec<AIRNode>, }, RecordPat { path: TypePath, fields: Vec<AirRecordPatternField>, rest: bool, }, TuplePat { elems: Vec<AIRNode>, }, ListPat { elems: Vec<AIRNode>, rest: Option<Box<AIRNode>>, }, OrPat { alternatives: Vec<AIRNode>, }, GuardPat { pattern: Box<AIRNode>, guard: Box<AIRNode>, }, RangePat { lo: Box<AIRNode>, hi: Box<AIRNode>, inclusive: bool, }, RestPat, Error,
}
Expand description

Discriminant and typed children of an AIRNode.

Children are structured per variant (not a flat Vec<AIRNode>), mirroring the AST but lowered into the unified AIR representation.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Module

The root node of a compiled Bock source file.

Fields

§annotations: Vec<Annotation>

Module-level annotations (@context, @requires, etc.).

§imports: Vec<AIRNode>

Import declarations (NodeKind::ImportDecl).

§items: Vec<AIRNode>

Top-level items.

§

ImportDecl

An import declaration: import Foo.Bar.{ A, B }.

Fields

§

FnDecl

A function declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§is_async: bool
§name: Ident
§generic_params: Vec<GenericParam>
§params: Vec<AIRNode>

Parameter nodes (NodeKind::Param).

§return_type: Option<Box<AIRNode>>

Optional return-type node (a type-expression variant).

§effect_clause: Vec<TypePath>

Effect names listed in the with clause.

§where_clause: Vec<TypeConstraint>
§body: Box<AIRNode>

Body block node (NodeKind::Block).

§

RecordDecl

A record (value-type) declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§generic_params: Vec<GenericParam>
§

EnumDecl

An enum (algebraic data type) declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§generic_params: Vec<GenericParam>
§variants: Vec<AIRNode>

Variant nodes (unit, struct, or tuple — see AST EnumVariant).

§

EnumVariant

An enum variant — unit, struct-like, or tuple-like.

Fields

§name: Ident
§payload: EnumVariantPayload

None = unit; Some = struct fields or positional types.

§

ClassDecl

A class declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§generic_params: Vec<GenericParam>
§traits: Vec<TypePath>
§methods: Vec<AIRNode>

Method nodes (NodeKind::FnDecl).

§

TraitDecl

A trait (or platform-trait) declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§is_platform: bool
§name: Ident
§generic_params: Vec<GenericParam>
§associated_types: Vec<AssociatedType>
§methods: Vec<AIRNode>

Method nodes (NodeKind::FnDecl).

§

ImplBlock

An impl Trait for Type or impl Type block.

Fields

§annotations: Vec<Annotation>
§generic_params: Vec<GenericParam>
§trait_path: Option<TypePath>
§target: Box<AIRNode>

The type being implemented (a type-expression node).

§where_clause: Vec<TypeConstraint>
§methods: Vec<AIRNode>

Method nodes (NodeKind::FnDecl).

§

EffectDecl

An algebraic effect declaration.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§generic_params: Vec<GenericParam>
§components: Vec<TypePath>

Component effects for composite effects: effect IO = Log + Clock.

§operations: Vec<AIRNode>

Operation nodes (NodeKind::FnDecl).

§

TypeAlias

A type alias: type Name[T] = ....

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§generic_params: Vec<GenericParam>
§ty: Box<AIRNode>

The aliased type-expression node.

§where_clause: Vec<TypeConstraint>
§

ConstDecl

A constant declaration: const NAME: Type = value.

Fields

§annotations: Vec<Annotation>
§visibility: Visibility
§name: Ident
§ty: Box<AIRNode>

Type annotation node (type-expression variant).

§value: Box<AIRNode>

Initialiser expression node.

§

ModuleHandle

A module-level handle Effect with handler declaration.

Fields

§effect: TypePath
§handler: Box<AIRNode>

Handler expression node.

§

PropertyTest

A property("name") { forall(...) { ... } } property-based test.

Fields

§name: String
§body: Box<AIRNode>

Body block node (NodeKind::Block).

§

Param

A single function/lambda parameter.

Fields

§pattern: Box<AIRNode>

Pattern node (a pattern variant).

§ty: Option<Box<AIRNode>>

Optional type annotation node (type-expression variant).

§default: Option<Box<AIRNode>>

Optional default-value expression node.

§

TypeNamed

A named type, possibly with generic arguments: List[Int].

Fields

§args: Vec<AIRNode>

Generic argument nodes (type-expression variants).

§

TypeTuple

A tuple type: (Int, String).

Fields

§elems: Vec<AIRNode>

Element type nodes (type-expression variants).

§

TypeFunction

A function type: Fn(Int) -> String with Log.

Fields

§params: Vec<AIRNode>

Parameter type nodes (type-expression variants).

§ret: Box<AIRNode>

Return type node (type-expression variant).

§effects: Vec<TypePath>

Effects listed in the with clause.

§

TypeOptional

An optional type: Int?.

Fields

§inner: Box<AIRNode>

Inner type node (type-expression variant).

§

TypeSelf

The Self type in a trait/impl context.

§

Literal

A literal value.

Fields

§

Identifier

An identifier reference.

Fields

§name: Ident
§

BinaryOp

A binary operation: a + b.

Fields

§left: Box<AIRNode>
§right: Box<AIRNode>
§

UnaryOp

A unary operation: -x, !flag.

Fields

§operand: Box<AIRNode>
§

Assign

An assignment expression: x = 5, x += 1.

Fields

§target: Box<AIRNode>
§value: Box<AIRNode>
§

Call

A function call: f(a, b).

Fields

§callee: Box<AIRNode>
§args: Vec<AirArg>
§type_args: Vec<AIRNode>
§

MethodCall

A method call: obj.method(a, b).

Fields

§receiver: Box<AIRNode>
§method: Ident
§type_args: Vec<AIRNode>
§args: Vec<AirArg>
§

FieldAccess

Field access: obj.field.

Fields

§object: Box<AIRNode>
§field: Ident
§

Index

Index access: arr[i].

Fields

§object: Box<AIRNode>
§index: Box<AIRNode>
§

Propagate

Error propagation: expr? — maps to spec’s Propagate.

Fields

§expr: Box<AIRNode>
§

Lambda

A lambda: (x) => x * 2.

Fields

§params: Vec<AIRNode>

Parameter nodes (NodeKind::Param).

§body: Box<AIRNode>

Body expression node.

§

Pipe

Pipe operator: data |> parse.

Fields

§left: Box<AIRNode>
§right: Box<AIRNode>
§

Compose

Function composition: parse >> validate.

Fields

§left: Box<AIRNode>
§right: Box<AIRNode>
§

Await

An await expression.

Fields

§expr: Box<AIRNode>
§

Range

A range: 1..10 (exclusive) or 1..=10 (inclusive).

Fields

§inclusive: bool
§

RecordConstruct

Record construction: User { id: 1, name, ..defaults }.

Fields

§spread: Option<Box<AIRNode>>
§

ListLiteral

List literal: [1, 2, 3].

Fields

§elems: Vec<AIRNode>
§

MapLiteral

Map literal: {"key": value}.

Fields

§entries: Vec<AirMapEntry>
§

SetLiteral

Set literal: #{"a", "b"}.

Fields

§elems: Vec<AIRNode>
§

TupleLiteral

Tuple literal: ("hello", 42).

Fields

§elems: Vec<AIRNode>
§

Interpolation

String interpolation: "Hello, ${name}!".

§

Placeholder

A placeholder _ used in pipe expressions.

§

Unreachable

unreachable — a diverging expression.

§

ResultConstruct

Explicit Ok(v) or Err(e) result construction.

Fields

§

If

An if / if-let expression.

Fields

§let_pattern: Option<Box<AIRNode>>

For if let pat = expr, holds the pattern node.

§condition: Box<AIRNode>
§then_block: Box<AIRNode>

Then-branch block node (NodeKind::Block).

§else_block: Option<Box<AIRNode>>

Optional else branch (block or nested if node).

§

Guard

A guard condition else { ... } statement.

When let_pattern is Some, this is guard (let pat = expr) else { ... }.

Fields

§let_pattern: Option<Box<AIRNode>>

For guard (let pat = expr), the pattern node.

§condition: Box<AIRNode>
§else_block: Box<AIRNode>
§

Match

A match expression.

Fields

§scrutinee: Box<AIRNode>
§arms: Vec<AIRNode>

Match arm nodes (NodeKind::MatchArm).

§

MatchArm

One arm of a match expression.

Fields

§pattern: Box<AIRNode>

Pattern node (a pattern variant).

§guard: Option<Box<AIRNode>>

Optional guard expression.

§body: Box<AIRNode>

Body expression node.

§

For

A for loop.

Fields

§pattern: Box<AIRNode>

Loop variable pattern node (a pattern variant).

§iterable: Box<AIRNode>
§body: Box<AIRNode>
§

While

A while loop.

Fields

§condition: Box<AIRNode>
§body: Box<AIRNode>
§

Loop

An infinite loop.

Fields

§body: Box<AIRNode>
§

Block

A block of statements with an optional tail expression.

Fields

§stmts: Vec<AIRNode>
§

Return

A return expression.

Fields

§

Break

A break expression, optionally with a value.

Fields

§

Continue

A continue expression.

§

LetBinding

A let [mut] pattern [: Type] = value binding.

Fields

§is_mut: bool
§pattern: Box<AIRNode>
§value: Box<AIRNode>
§

Move

An explicit move of ownership: move expr.

Fields

§expr: Box<AIRNode>
§

Borrow

An immutable borrow: &expr.

Fields

§expr: Box<AIRNode>
§

MutableBorrow

A mutable borrow: &mut expr.

Fields

§expr: Box<AIRNode>
§

EffectOp

An algebraic-effect operation invocation.

Fields

§effect: TypePath
§operation: Ident
§args: Vec<AirArg>
§

HandlingBlock

A handling (Effect with handler, ...) { body } block.

Fields

§body: Box<AIRNode>
§

EffectRef

A reference to an effect type (used in type positions and signatures).

Fields

§

WildcardPat

_ — wildcard pattern, matches anything.

§

BindPat

name or mut name — bind pattern.

Fields

§name: Ident
§is_mut: bool
§

LiteralPat

A literal pattern: 42, "hello", true.

Fields

§

ConstructorPat

An enum constructor pattern: Some(x), Ok(v).

Fields

§fields: Vec<AIRNode>

Positional field pattern nodes.

§

RecordPat

A record pattern: User { name, age }.

Fields

§rest: bool

true when the pattern contains a .. rest marker.

§

TuplePat

A tuple pattern: (a, b, c).

Fields

§elems: Vec<AIRNode>
§

ListPat

A list pattern: [head, ..tail].

Fields

§elems: Vec<AIRNode>
§

OrPat

An or-pattern: A | B.

Fields

§alternatives: Vec<AIRNode>
§

GuardPat

A guard pattern (in pattern-matching guard position).

Fields

§pattern: Box<AIRNode>
§guard: Box<AIRNode>
§

RangePat

A range pattern: 1..10 or 1..=10.

Fields

§inclusive: bool
§

RestPat

A rest pattern .. (inside list/tuple patterns).

§

Error

An error-recovery node wrapping tokens that could not be lowered.

Trait Implementations§

Source§

impl Clone for NodeKind

Source§

fn clone(&self) -> NodeKind

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 NodeKind

Source§

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

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

impl PartialEq for NodeKind

Source§

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

Auto Trait Implementations§

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> 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> 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<T> Paint for T
where T: ?Sized,

Source§

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 primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

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>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

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 bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

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 mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
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.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

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);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
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.