Skip to main content

SyntaxKind

Enum SyntaxKind 

Source
pub enum SyntaxKind {
Show 212 variants ERROR = 0, EOF, WHITESPACE, LINEBREAK, COMMENT_LINE, COMMENT_BLOCK, INTEGER, STRING, ADDRESS_LIT, IDENT_LIT, IDENT, KW_TRUE, KW_FALSE, KW_NONE, KW_ADDRESS, KW_BOOL, KW_FIELD, KW_GROUP, KW_SCALAR, KW_SIGNATURE, KW_STRING, KW_RECORD, KW_DYN, KW_IDENTIFIER, KW_FINAL_UPPER, KW_I8, KW_I16, KW_I32, KW_I64, KW_I128, KW_U8, KW_U16, KW_U32, KW_U64, KW_U128, KW_IF, KW_ELSE, KW_FOR, KW_IN, KW_RETURN, KW_LET, KW_CONST, KW_CONSTANT, KW_FINAL, KW_VIEW, KW_FN, KW_FN_UPPER, KW_STRUCT, KW_CONSTRUCTOR, KW_INTERFACE, KW_PROGRAM, KW_IMPORT, KW_MAPPING, KW_STORAGE, KW_NETWORK, KW_ALEO, KW_SCRIPT, KW_BLOCK, KW_PUBLIC, KW_PRIVATE, KW_AS, KW_SELF, KW_ASSERT, KW_ASSERT_EQ, KW_ASSERT_NEQ, L_PAREN, R_PAREN, L_BRACKET, R_BRACKET, L_BRACE, R_BRACE, COMMA, DOT, DOT_DOT, DOT_DOT_EQ, SEMICOLON, COLON, COLON_COLON, QUESTION, ARROW, FAT_ARROW, UNDERSCORE, AT, EQ, PLUS_EQ, MINUS_EQ, STAR_EQ, SLASH_EQ, PERCENT_EQ, STAR2_EQ, AMP2_EQ, PIPE2_EQ, AMP_EQ, PIPE_EQ, CARET_EQ, SHL_EQ, SHR_EQ, PLUS, MINUS, STAR, SLASH, PERCENT, STAR2, EQ2, BANG_EQ, LT, LT_EQ, GT, GT_EQ, AMP2, PIPE2, BANG, AMP, PIPE, CARET, SHL, SHR, ROOT, PROGRAM_DECL, IMPORT, MAIN_CONTENTS, MODULE_CONTENTS, FUNCTION_DEF, FINAL_FN_DEF, VIEW_FN_DEF, CONSTRUCTOR_DEF, STRUCT_DEF, RECORD_DEF, STRUCT_MEMBER, STRUCT_MEMBER_PUBLIC, STRUCT_MEMBER_PRIVATE, STRUCT_MEMBER_CONSTANT, MAPPING_DEF, STORAGE_DEF, GLOBAL_CONST, INTERFACE_DEF, FN_PROTOTYPE_DEF, RECORD_PROTOTYPE_DEF, ANNOTATION, ANNOTATION_PAIR, PARAM, PARAM_PUBLIC, PARAM_PRIVATE, PARAM_CONSTANT, PARAM_LIST, RETURN_TYPE, CONST_PARAM, CONST_PARAM_LIST, CONST_ARG_LIST, DYNAMIC_CALL_RETURN_TYPE, ARRAY_LENGTH, LET_STMT, CONST_STMT, RETURN_STMT, EXPR_STMT, ASSIGN_STMT, COMPOUND_ASSIGN_STMT, IF_STMT, FOR_STMT, FOR_INCLUSIVE_STMT, BLOCK, ASSERT_STMT, ASSERT_EQ_STMT, ASSERT_NEQ_STMT, IDENT_PATTERN, TUPLE_PATTERN, WILDCARD_PATTERN, BINARY_EXPR, UNARY_EXPR, CALL_EXPR, METHOD_CALL_EXPR, FIELD_EXPR, INDEX_EXPR, CAST_EXPR, TERNARY_EXPR, ARRAY_EXPR, TUPLE_EXPR, STRUCT_EXPR, STRUCT_LOCATOR_EXPR, STRUCT_FIELD_INIT, STRUCT_FIELD_SHORTHAND, PATH_EXPR, PATH_LOCATOR_EXPR, PROGRAM_REF_EXPR, SELF_EXPR, BLOCK_KW_EXPR, NETWORK_KW_EXPR, PAREN_EXPR, LITERAL_FIELD, LITERAL_GROUP, LITERAL_SCALAR, LITERAL_INT, LITERAL_STRING, LITERAL_ADDRESS, LITERAL_BOOL, LITERAL_NONE, LITERAL_IDENT, REPEAT_EXPR, FINAL_EXPR, TUPLE_ACCESS_EXPR, DYNAMIC_OP_EXPR, TYPE_PATH, TYPE_PRIMITIVE, TYPE_LOCATOR, TYPE_ARRAY, TYPE_VECTOR, TYPE_TUPLE, TYPE_OPTIONAL, TYPE_FINAL, TYPE_MAPPING, TYPE_DYN_RECORD, PARENT_LIST, // some variants omitted
}
Expand description

All syntax kinds for Leo tokens and nodes.

This enum is intentionally flat (not nested) to satisfy rowan’s requirement for a #[repr(u16)] type. Categories are indicated by comments and helper methods like is_trivia() and is_keyword().

Variants§

§

ERROR = 0

Error node for wrapping parse errors and invalid tokens.

§

EOF

End of file marker.

§

WHITESPACE

Horizontal whitespace: spaces, tabs, form feeds.

§

LINEBREAK

Line breaks: \n or \r\n.

§

COMMENT_LINE

Line comment: // …

§

COMMENT_BLOCK

Block comment: /* … */

§

INTEGER

Integer literal: 123, 0xFF, 0b101, 0o77

§

STRING

String literal: “…”

§

ADDRESS_LIT

Address literal: aleo1…

§

IDENT_LIT

Identifier literal: ‘foo’

§

IDENT

Identifier: foo, Bar, _baz Note: Complex identifiers (paths, program IDs, locators) are deferred to Phase 2. The lexer produces simple IDENT tokens; the parser handles disambiguation of foo::bar, foo.aleo, foo.aleo::bar patterns.

§

KW_TRUE

true

§

KW_FALSE

false

§

KW_NONE

none

§

KW_ADDRESS

address

§

KW_BOOL

bool

§

KW_FIELD

field

§

KW_GROUP

group

§

KW_SCALAR

scalar

§

KW_SIGNATURE

signature

§

KW_STRING

string

§

KW_RECORD

record

§

KW_DYN

dyn

§

KW_IDENTIFIER

identifier

§

KW_FINAL_UPPER

Final

§

KW_I8

i8

§

KW_I16

i16

§

KW_I32

i32

§

KW_I64

i64

§

KW_I128

i128

§

KW_U8

u8

§

KW_U16

u16

§

KW_U32

u32

§

KW_U64

u64

§

KW_U128

u128

§

KW_IF

if

§

KW_ELSE

else

§

KW_FOR

for

§

KW_IN

in

§

KW_RETURN

return

§

KW_LET

let

§

KW_CONST

const

§

KW_CONSTANT

constant

§

KW_FINAL

final

§

KW_VIEW

view

§

KW_FN

fn

§

KW_FN_UPPER

Fn

§

KW_STRUCT

struct

§

KW_CONSTRUCTOR

constructor

§

KW_INTERFACE

interface

§

KW_PROGRAM

program

§

KW_IMPORT

import

§

KW_MAPPING

mapping

§

KW_STORAGE

storage

§

KW_NETWORK

network

§

KW_ALEO

aleo

§

KW_SCRIPT

script

§

KW_BLOCK

block

§

KW_PUBLIC

public

§

KW_PRIVATE

private

§

KW_AS

as

§

KW_SELF

self

§

KW_ASSERT

assert

§

KW_ASSERT_EQ

assert_eq

§

KW_ASSERT_NEQ

assert_neq

§

L_PAREN

(

§

R_PAREN

)

§

L_BRACKET

[

§

R_BRACKET

]

§

L_BRACE

{

§

R_BRACE

}

§

COMMA

,

§

DOT

.

§

DOT_DOT

..

§

DOT_DOT_EQ

..=

§

SEMICOLON

;

§

COLON

:

§

COLON_COLON

::

§

QUESTION

?

§

ARROW

->

§

FAT_ARROW

=>

§

UNDERSCORE

_

§

AT

@

§

EQ

=

§

PLUS_EQ

+=

§

MINUS_EQ

-=

§

STAR_EQ

*=

§

SLASH_EQ

/=

§

PERCENT_EQ

%=

§

STAR2_EQ

**=

§

AMP2_EQ

&&=

§

PIPE2_EQ

||=

§

AMP_EQ

&=

§

PIPE_EQ

|=

§

CARET_EQ

^=

§

SHL_EQ

<<=

§

SHR_EQ

>>=

§

PLUS

+

§

MINUS

-

§

STAR

*

§

SLASH

/

§

PERCENT

%

§

STAR2

**

§

EQ2

==

§

BANG_EQ

!=

§

LT

<

§

LT_EQ

<=

§

GT

>

§

GT_EQ

>=

§

AMP2

&&

§

PIPE2

||

§

BANG

!

§

AMP

&

§

PIPE

|

§

CARET

^

§

SHL

<<

§

SHR

>>

§

ROOT

Root node of the syntax tree.

§

PROGRAM_DECL

Program declaration: program foo.aleo { ... }

§

IMPORT

Import statement: import foo.aleo;

§

MAIN_CONTENTS

Main file contents.

§

MODULE_CONTENTS

Module file contents.

§

FUNCTION_DEF

Function definition.

§

FINAL_FN_DEF

Final function definition: final fn ...

§

VIEW_FN_DEF

View function definition: view fn .... Read-only V15 entry point.

§

CONSTRUCTOR_DEF

Constructor definition.

§

STRUCT_DEF

Struct definition.

§

RECORD_DEF

Record definition.

§

STRUCT_MEMBER

Struct member declaration.

§

STRUCT_MEMBER_PUBLIC

Public struct member: public name: Type

§

STRUCT_MEMBER_PRIVATE

Private struct member: private name: Type

§

STRUCT_MEMBER_CONSTANT

Constant struct member: constant name: Type

§

MAPPING_DEF

Mapping definition.

§

STORAGE_DEF

Storage definition.

§

GLOBAL_CONST

Global constant definition.

§

INTERFACE_DEF

Interface declaration.

§

FN_PROTOTYPE_DEF

Function prototype (in interface).

§

RECORD_PROTOTYPE_DEF

Record prototype (in interface).

§

ANNOTATION

Annotation: @foo

§

ANNOTATION_PAIR

Annotation key-value pair: key = "value"

§

PARAM

Parameter in a function signature.

§

PARAM_PUBLIC

Public parameter: public name: Type

§

PARAM_PRIVATE

Private parameter: private name: Type

§

PARAM_CONSTANT

Constant parameter: constant name: Type

§

PARAM_LIST

Parameter list: (a: u32, b: u32)

§

RETURN_TYPE

Function output type.

§

CONST_PARAM

Const generic parameter.

§

CONST_PARAM_LIST

Const generic parameter list.

§

CONST_ARG_LIST

Const generic argument list.

§

DYNAMIC_CALL_RETURN_TYPE

Visibility-annotated return type for _dynamic_call (e.g. public u64).

§

ARRAY_LENGTH

Array length expression wrapper in [T; N].

§

LET_STMT

Let statement: let x = ...;

§

CONST_STMT

Const statement: const x = ...;

§

RETURN_STMT

Return statement: return ...;

§

EXPR_STMT

Expression statement: foo();

§

ASSIGN_STMT

Assignment statement: x = ...;

§

COMPOUND_ASSIGN_STMT

Compound assignment statement: x += ...;, x -= ...;, etc.

§

IF_STMT

If statement: if ... { } else { }

§

FOR_STMT

For loop: for i in 0..10 { }

§

FOR_INCLUSIVE_STMT

Inclusive for loop: for i in 0..=10 { }

§

BLOCK

Block: { ... }

§

ASSERT_STMT

Assert statement: assert(...);

§

ASSERT_EQ_STMT

Assert equals statement: assert_eq(...);

§

ASSERT_NEQ_STMT

Assert not equals statement: assert_neq(...);

§

IDENT_PATTERN

Identifier pattern: x

§

TUPLE_PATTERN

Tuple pattern: (a, b, c)

§

WILDCARD_PATTERN

Wildcard pattern: _

§

BINARY_EXPR

Binary expression: a + b

§

UNARY_EXPR

Unary expression: !a, -a

§

CALL_EXPR

Function call: foo(a, b)

§

METHOD_CALL_EXPR

Method call: a.foo(b)

§

FIELD_EXPR

Member access: a.b

§

INDEX_EXPR

Array/tuple index: a[0]

§

CAST_EXPR

Cast expression: a as u32

§

TERNARY_EXPR

Ternary expression: a ? b : c

§

ARRAY_EXPR

Array literal: [1, 2, 3]

§

TUPLE_EXPR

Tuple literal: (1, 2, 3)

§

STRUCT_EXPR

Struct literal: Foo { a: 1, b: 2 }

§

STRUCT_LOCATOR_EXPR

Struct locator literal: program.aleo::Type { a: 1, b: 2 }

§

STRUCT_FIELD_INIT

Struct field initializer: a: 1

§

STRUCT_FIELD_SHORTHAND

Struct field shorthand: { x } (equivalent to { x: x })

§

PATH_EXPR

Path expression: foo::bar

§

PATH_LOCATOR_EXPR

Path locator expression: program.aleo::function

§

PROGRAM_REF_EXPR

Program reference expression: name.aleo (without ::Type suffix).

§

SELF_EXPR

Self expression: self

§

BLOCK_KW_EXPR

Block keyword expression: block

§

NETWORK_KW_EXPR

Network keyword expression: network

§

PAREN_EXPR

Parenthesized expression: (a + b)

§

LITERAL_FIELD

Field literal: 42field

§

LITERAL_GROUP

Group literal: 42group

§

LITERAL_SCALAR

Scalar literal: 42scalar

§

LITERAL_INT

Integer literal: 42u32, 42 (unsuffixed)

§

LITERAL_STRING

String literal: "hello"

§

LITERAL_ADDRESS

Address literal: aleo1...

§

LITERAL_BOOL

Boolean literal: true, false

§

LITERAL_NONE

None literal: none

§

LITERAL_IDENT

Identifier literal: 'foo'

§

REPEAT_EXPR

Repeat expression: [0u8; 32]

§

FINAL_EXPR

Async expression: async foo()

§

TUPLE_ACCESS_EXPR

Tuple access: a.0

§

DYNAMIC_OP_EXPR

Dynamic interface access. Covers three surface forms:

  • function call: Interface @ (target) :: func(args)
  • storage/vector op: Interface @ (target) :: member.op(args)
  • singleton bare read: Interface @ (target) :: storage
§

TYPE_PATH

Named/path type: Foo, foo::Bar

§

TYPE_PRIMITIVE

Primitive type: u32, bool, field, etc.

§

TYPE_LOCATOR

Locator type: program.aleo::Type

§

TYPE_ARRAY

Array type: [u32; 10]

§

TYPE_VECTOR

Vector type: [u32]

§

TYPE_TUPLE

Tuple type: (u32, u32)

§

TYPE_OPTIONAL

Optional type: u32? (Future feature)

§

TYPE_FINAL

Final type: Final<Foo>

§

TYPE_MAPPING

Mapping type in storage.

§

TYPE_DYN_RECORD

Dynamic record type: dyn record

§

PARENT_LIST

Parent list: Foo + Bar

Implementations§

Source§

impl SyntaxKind

Source

pub fn is_trivia(self) -> bool

Check if this is a trivia token (whitespace or comment).

Source

pub fn is_keyword(self) -> bool

Check if this is a keyword.

Source

pub fn is_type_keyword(self) -> bool

Check if this is a type keyword.

Source

pub fn is_literal(self) -> bool

Check if this is a literal token.

Source

pub fn is_literal_node(self) -> bool

Check if this is a literal node kind.

Source

pub fn is_type(self) -> bool

Check if this is a type node kind.

Source

pub fn is_expression(self) -> bool

Check if this is an expression node kind.

Source

pub fn is_statement(self) -> bool

Check if this is a statement node kind.

Source

pub fn is_punctuation(self) -> bool

Check if this is a punctuation token.

Source

pub fn is_operator(self) -> bool

Check if this is an operator token.

Source

pub fn user_friendly_name(self) -> &'static str

Returns a user-friendly name for this token kind, suitable for error messages.

Trait Implementations§

Source§

impl Clone for SyntaxKind

Source§

fn clone(&self) -> SyntaxKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntaxKind

Source§

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

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

impl From<SyntaxKind> for SyntaxKind

Source§

fn from(kind: SyntaxKind) -> Self

Converts to this type from the input type.
Source§

impl Hash for SyntaxKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for SyntaxKind

Source§

fn cmp(&self, other: &SyntaxKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SyntaxKind

Source§

fn eq(&self, other: &SyntaxKind) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 PartialOrd for SyntaxKind

Source§

fn partial_cmp(&self, other: &SyntaxKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for SyntaxKind

Source§

impl Eq for SyntaxKind

Source§

impl StructuralPartialEq for SyntaxKind

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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.