Enum Kind

pub enum Kind {
Show 24 variants Eof = 0, Whitespace = 1, Comment = 2, CdcOrCdo = 3, Number = 4, Dimension = 5, BadString = 6, BadUrl = 7, Ident = 8, Function = 9, AtKeyword = 10, Hash = 11, String = 12, Url = 13, Delim = 16, Colon = 17, Semicolon = 18, Comma = 19, LeftSquare = 20, RightSquare = 21, LeftParen = 22, RightParen = 23, LeftCurly = 24, RightCurly = 25,
}
Expand description

Kind represents the token “Type”, categorised mostly by the token types within the CSS Syntax spec.

Maintaining parity with the spec makes it easier to reason about logica round the parser, despite it being possible to group a bunch of these tokens into a single “delimiter” token.

Importantly, Kind is represented as u8 and must only use the 5 low bits, because the upper 3 bits get used to house details about each kind, that a token would be interested in learning about.

Variants§

§

Eof = 0

Represents the <eof-token> defined in CSS. While CSS stipulates that this token is never produced by a tokenizer, this [Lexer][crate::Lexer] will produce <eof-token>s if the underlying source has been fully consumed.

§

Whitespace = 1

Represents the <whitespace-token> defined in CSS.

<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<whitespace-token>
 │├─╭─ <whitespace> ─╮─┤│
    ╰────────────────╯

While CSS stipulates that this token represents collapsed whitespace, it is possible for [Lexer][crate::Lexer] to produce multiple consecutive Kind::Whitespace tokens if the [Feature::SeparateWhitespace][crate::Feature::SeparateWhitespace] runtime feature is enabled. In this case, <whitespace-token> becomes:

<whitespace-token>
 │├──╮─╭─ " " ───────╮─╭──┤│
     │ ╰─────────────╯ │
     ├─╭─ "\t" ──────╮─┤
     │ ╰─────────────╯ │
     ╰─╭─ <newline> ─╮─╯
       ╰─────────────╯
§

Comment = 2

Represents the <comment> defined in CSS. While CSS stipulates comment tokens are not produced during tokenization, they are for this [Lexer][crate::Lexer] as they’re needed in order to preserve them.

<comment>
           ╭──────────────────────────────────────────╮
 │├─ "/*" ─╯-╭─ (anything but "*" followed by "/") ─╮─╰─ "*/" ─┤│
             ╰──────────────────────────────────────╯

It is possible for [Lexer][crate::Lexer] to produce Kind::Whitespace tokens that begin // if the [Feature::SingleLineComments][crate::Feature::SingleLineComments] runtime feature is enabled. In this mode, <comment> becomes:

<comment>
              ╭──────────────────────────────────────────╮
 │├──╮─ "/*" ─╯-╭─ (anything but "*" followed by "/") ─╮─╰─ "*/" ─╭─┤│
     │          ╰──────────────────────────────────────╯          │
     │              ╭───────────────────────────╮                 │
     ╰─ "//" ───────╯-╭─ (anything but "\n") ─╮─╰─ "\n" ──────────╯
                      ╰───────────────────────╯
§

CdcOrCdo = 3

Represents both the <cdc-token> and <cdo-token>s defined in CSS. While CSS separates these tokens, they’re only useful representations at the top-level stylesheet, anywhere else they represent a parse error, and it’s a little pointless to define two tokens types for what amounts to a parse error.

<cdo-token>
 │├─ "<!--" ─┤│

<cdc-token>
 │├─ "-->" ─┤│

<cdc-or-cdo-token> (Not part of the CSS specification)
 │├──╮─ <cdo-token> ─╭──┤│
     ╰─ <crc-token> ─╯
§

Number = 4

Represents the <number-token>.


<number-token>
    ╭─ "+" ─╮
 │├─├───────┤───╭─ [digit] ─╮─ "." ─╭─ [digit] ─╮──╭───╮──────────────────────────────────╭──┤│
    ╰─ "-" ─╯ │ ╰───────────╯       ╰───────────╯  │   │         ╭─ "+" ─╮                │
              ├───────── ╭─ [digit] ─╮─────────────┤   ├─ "e" ─╭─├───────┤──╭─ [digit] ─╮─╯
              │          ╰───────────╯             │   ╰─ "E" ─╯ ╰─ "-" ─╯  ╰───────────╯
              ╰──── "." ─╭─ [digit] ─╮─────────────╯
                         ╰───────────╯
§

Dimension = 5

Represents the <dimension-token>.

Here we deviate from the spec slightly, which has both <dimension-token> and <percentage-token>. <percentage-token> represents a dimension with a % symbol, but having this as a separate token results in more work in the parser for little gain in the Lexer. So instead this lexer does not have a <percentage-token> and instead folds the grammar for it inside of <dimension-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<ident-token>
    ╭───────────────── "--" ─────────────────────╮  ╭───────────────────────────────────────────╮
 │├─╯─╮───────╭─╮─ [a-z, A-Z, "_", non-ASCII] ─╭─╰──╯─╭─╮─ [a-z, A-Z, 0-9, "_", non-ASCII] ─╭─╮─╰──┤│
      ╰─ "-" ─╯ ╰──────── <escape> ────────────╯      │ ╰──────────── <escape> ─────────────╯ │
                                                      ╰───────────────────────────────────────╯

<number-token>
    ╭─ "+" ─╮
 │├─├───────┤─╮─╭─ [digit] ─╮─ "." ─╭─ [digit] ─╮──╭───╮──────────────────────────────────╭──┤│
    ╰─ "-" ─╯ │ ╰───────────╯       ╰───────────╯  │   │         ╭─ "+" ─╮                │
              ├───────── ╭─ [digit] ─╮─────────────┤   ├─ "e" ─╭─├───────┤──╭─ [digit] ─╮─╯
              │          ╰───────────╯             │   ╰─ "E" ─╯ ╰─ "-" ─╯  ╰───────────╯
              ╰──── "." ─╭─ [digit] ─╮─────────────╯
                         ╰───────────╯

<dimension-token>
 │├─ <number-token> ─ <ident-token> ─┤│

<dimension-token> // Refined for this lexer, not true to the standard.
 │├─ <number-token> ─╮─ <ident-token> ─╭──┤│
                     ╰────── "%" ──────╯
§

BadString = 6

Represents the <bad-string-token>. This token is a failure to fully lex the <string-token>.

§

BadUrl = 7

Represents the <bad-url-token>. This token is a failure to fully lex the <url-token>.

§

Ident = 8

Represents the <ident-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ─────╭──┤│
     ├─ "\t" ────┤
     ╰─ newline ─╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<ident-token>
    ╭───────────────── "--" ─────────────────────╮  ╭───────────────────────────────────────────╮
 │├─╯─╮───────╭─╮─ [a-z, A-Z, "_", non-ASCII] ─╭─╰──╯─╭─╮─ [a-z, A-Z, 0-9, "_", non-ASCII] ─╭─╮─╰──┤│
      ╰─ "-" ─╯ ╰──────── <escape> ────────────╯      │ ╰──────────── <escape> ─────────────╯ │
                                                      ╰───────────────────────────────────────╯
§

Function = 9

Represents the <function-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<ident-token>
    ╭───────────────── "--" ─────────────────────╮  ╭───────────────────────────────────────────╮
 │├─╯─╮───────╭─╮─ [a-z, A-Z, "_", non-ASCII] ─╭─╰──╯─╭─╮─ [a-z, A-Z, 0-9, "_", non-ASCII] ─╭─╮─╰──┤│
      ╰─ "-" ─╯ ╰──────── <escape> ────────────╯      │ ╰──────────── <escape> ─────────────╯ │
                                                      ╰───────────────────────────────────────╯

<function-token>
 │├─ <ident-token> ─ "(" ─┤│
§

AtKeyword = 10

Represents the <at-keyword-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<ident-token>
    ╭───────────────── "--" ─────────────────────╮  ╭───────────────────────────────────────────╮
 │├─╯─╮───────╭─╮─ [a-z, A-Z, "_", non-ASCII] ─╭─╰──╯─╭─╮─ [a-z, A-Z, 0-9, "_", non-ASCII] ─╭─╮─╰──┤│
      ╰─ "-" ─╯ ╰──────── <escape> ────────────╯      │ ╰──────────── <escape> ─────────────╯ │
                                                      ╰───────────────────────────────────────╯

<at-keyword-token>
 │├─ "@" ─ <ident-token> ─┤│
§

Hash = 11

Represents the <hash-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<hash-token>
 │├─ "#" ──╭─╮─ [a-z, A-Z, 0-9, "_", "-", non-ASCII] ─╭─╮─┤│
           │ ╰─────────────── <escape> ───────────────╯ │
           ╰────────────────────────────────────────────╯
§

String = 12

Represents the <string-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<string-token>
            ╭───────────────────────────────────╮
 │├─╮─ """ ─╯─╭─╮─ [not """, "\", newline] ─╭─╮─╰── """ ─╭─┤│
    │         │ ├──────── <escape> ─────────┤ │          │
    │         │ ╰───── "\" ─ <newline> ─────╯ │          │
    │         ╰───────────────────────────────╯          │
    │       ╭───────────────────────────────────╮        │
    ╰─ "'" ─╯─╭─╮─ [not """, "\", newline] ─╭─╮─╰── "'" ─╯
              │ ├──────── <escape> ─────────┤ │
              │ ╰───── "\" ─ <newline> ─────╯ │
              ╰───────────────────────────────╯
§

Url = 13

Represents the <url-token>.


<newline>
 │├──╮─ "\n" ───╭──┤│
     ├─ "\r\n" ─┤
     ├─ "\r" ───┤
     ╰─ "\f" ───╯

<whitespace>
 │├──╮─ " " ───────╭──┤│
     ├─ "\t" ──────┤
     ╰─ <newline> ─╯

<whitespace-token>
 │├─╭─ <whitespace> ─╮─┤│
    ╰────────────────╯

<ws*>
    ╭──────────────────────────╮
 │├─╯─╭─ <whitespace-token> ─╮─╰─┤│
      ╰──────────────────────╯

<hexdigit>
 │├─ [ 0-9, A-F, a-f ] ─┤│


<escape>
 │├─ "\" ─╮───── [not <newline> or <hexdigit>] ───╭─┤│
          ╰─╭── <hexdigit> ─╮──╮────────────────╭─╯
            ╰─ (1-6 times) ─╯  ╰─ <whitespace> ─╯

<ident-token>
    ╭───────────────── "--" ─────────────────────╮  ╭───────────────────────────────────────────╮
 │├─╯─╮───────╭─╮─ [a-z, A-Z, "_", non-ASCII] ─╭─╰──╯─╭─╮─ [a-z, A-Z, 0-9, "_", non-ASCII] ─╭─╮─╰──┤│
      ╰─ "-" ─╯ ╰──────── <escape> ────────────╯      │ ╰──────────── <escape> ─────────────╯ │
                                                      ╰───────────────────────────────────────╯

<url-token>
                                        ╭───────────────────────────────────────────────────────────────────╮
 │├─ <ident-token "url"> ─ "(" ─ <ws*> ─╯─╭─╮─ [not """ "'" "(" ")" "\" <whitespace> or non-printable] ─╭─╮─╰─ <ws*> ─ ")" ─┤│
                                          │ ╰──────────────────────── <escape> ─────────────────────────╯ │
                                          ╰───────────────────────────────────────────────────────────────╯
§

Delim = 16

Represents the <delim-token>. The <delim-token> has a value composed of a single code point.

<delim-token>
 │├─ [codepoint] ─┤│
§

Colon = 17

Represents the <colon-token>.

<colon-token>
 │├─ ":" ─┤│
§

Semicolon = 18

Represents the <semicolon-token>.

<semicolon-token>
 │├─ ";" ─┤│
§

Comma = 19

Represents the <comma-token>.

<comma-token>
 │├─ "," ─┤│
§

LeftSquare = 20

Represents the <[-token>.

<[-token>
 │├─ "[" ─┤│
§

RightSquare = 21

Represents the <]-token>.

<]-token>
 │├─ "]" ─┤│
§

LeftParen = 22

Represents the <(-token>.

<(-token>
 │├─ "(" ─┤│
§

RightParen = 23

Represents the <)-token>.

<)-token>
 │├─ ")" ─┤│
§

LeftCurly = 24

Represents the <{-token>.

<{-token>
 │├─ "{" ─┤│
§

RightCurly = 25

Represents the <}-token>.

<}-token>
 │├─ "}" ─┤│

Trait Implementations§

§

impl Clone for Kind

§

fn clone(&self) -> Kind

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Kind

§

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

Formats the value using the given formatter. Read more
§

impl Default for Kind

§

fn default() -> Kind

Returns the “default value” for a type. Read more
§

impl Display for Kind

§

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

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

impl From<AtKeyword> for Kind

Source§

fn from(value: AtKeyword) -> Self

Converts to this type from the input type.
Source§

impl From<ConditionKeyword> for Kind

Source§

fn from(value: ConditionKeyword) -> Self

Converts to this type from the input type.
§

impl From<Cursor> for Kind

§

fn from(cursor: Cursor) -> Kind

Converts to this type from the input type.
Source§

impl From<Function> for Kind

Source§

fn from(value: Function) -> Self

Converts to this type from the input type.
Source§

impl From<Hash> for Kind

Source§

fn from(value: Hash) -> Self

Converts to this type from the input type.
Source§

impl From<Ident> for Kind

Source§

fn from(value: Ident) -> Self

Converts to this type from the input type.
Source§

impl From<ParserCheckpoint> for Kind

Source§

fn from(value: ParserCheckpoint) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Kind

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
§

impl From<Token> for Kind

§

fn from(token: Token) -> Kind

Converts to this type from the input type.
Source§

impl From<Url> for Kind

Source§

fn from(value: Url) -> Self

Converts to this type from the input type.
§

impl Hash for Kind

§

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

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
§

impl Ord for Kind

§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

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

Restrict a value to a certain interval. Read more
§

impl PartialEq<Kind> for &Cursor

§

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

impl PartialEq<Kind> for Cursor

§

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

impl PartialEq<Kind> for PairWise

§

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

impl PartialEq<Kind> for SourceCursor<'_>

§

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

impl PartialEq<Kind> for Token

§

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

impl PartialEq<KindSet> for Kind

§

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

impl PartialEq for Kind

§

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

impl PartialOrd for Kind

§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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
§

impl Copy for Kind

§

impl Eq for Kind

§

impl StructuralPartialEq for Kind

Auto Trait Implementations§

§

impl Freeze for Kind

§

impl RefUnwindSafe for Kind

§

impl Send for Kind

§

impl Sync for Kind

§

impl Unpin for Kind

§

impl UnwindSafe for Kind

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.

§

impl<D> OwoColorize for D

§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either [OwoColorize::fg] or a color-specific method, such as [OwoColorize::green], Read more
§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either [OwoColorize::bg] or a color-specific method, such as [OwoColorize::on_yellow], Read more
§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.