Trait stylic::Stylize

source ·
pub trait Stylize: Sized + Sealed {
Show 60 methods // Provided methods fn fg(self, color: impl Into<Color>) -> Self { ... } fn bg(self, color: impl Into<Color>) -> Self { ... } fn underline_colored(self, color: impl Into<Color>) -> Self { ... } fn attributes(self, attrs: Attributes) -> Self { ... } fn bold(self) -> Self { ... } fn dim(self) -> Self { ... } fn italic(self) -> Self { ... } fn underline(self) -> Self { ... } fn blink(self) -> Self { ... } fn reverse(self) -> Self { ... } fn hidden(self) -> Self { ... } fn strikethrough(self) -> Self { ... } fn black(self) -> Self { ... } fn on_black(self) -> Self { ... } fn underline_black(self) -> Self { ... } fn red(self) -> Self { ... } fn on_red(self) -> Self { ... } fn underline_red(self) -> Self { ... } fn green(self) -> Self { ... } fn on_green(self) -> Self { ... } fn underline_green(self) -> Self { ... } fn yellow(self) -> Self { ... } fn on_yellow(self) -> Self { ... } fn underline_yellow(self) -> Self { ... } fn blue(self) -> Self { ... } fn on_blue(self) -> Self { ... } fn underline_blue(self) -> Self { ... } fn magenta(self) -> Self { ... } fn on_magenta(self) -> Self { ... } fn underline_magenta(self) -> Self { ... } fn cyan(self) -> Self { ... } fn on_cyan(self) -> Self { ... } fn underline_cyan(self) -> Self { ... } fn white(self) -> Self { ... } fn on_white(self) -> Self { ... } fn underline_white(self) -> Self { ... } fn bright_black(self) -> Self { ... } fn on_bright_black(self) -> Self { ... } fn underline_bright_black(self) -> Self { ... } fn bright_red(self) -> Self { ... } fn on_bright_red(self) -> Self { ... } fn underline_bright_red(self) -> Self { ... } fn bright_green(self) -> Self { ... } fn on_bright_green(self) -> Self { ... } fn underline_bright_green(self) -> Self { ... } fn bright_yellow(self) -> Self { ... } fn on_bright_yellow(self) -> Self { ... } fn underline_bright_yellow(self) -> Self { ... } fn bright_blue(self) -> Self { ... } fn on_bright_blue(self) -> Self { ... } fn underline_bright_blue(self) -> Self { ... } fn bright_magenta(self) -> Self { ... } fn on_bright_magenta(self) -> Self { ... } fn underline_bright_magenta(self) -> Self { ... } fn bright_cyan(self) -> Self { ... } fn on_bright_cyan(self) -> Self { ... } fn underline_bright_cyan(self) -> Self { ... } fn bright_white(self) -> Self { ... } fn on_bright_white(self) -> Self { ... } fn underline_bright_white(self) -> Self { ... }
}
Expand description

This trait provides methods for modifying the style of a value.

It is implemented for Styled and StyledLink, as well as Style itself.

Provided Methods§

source

fn fg(self, color: impl Into<Color>) -> Self

Set the foreground color.

Examples found in repository?
examples/pallete.rs (line 5)
3
4
5
6
7
fn main() {
    for i in 0..=255 {
        println!("{}", style(i).fg(i));
    }
}
source

fn bg(self, color: impl Into<Color>) -> Self

Set the background color.

source

fn underline_colored(self, color: impl Into<Color>) -> Self

Set the underline attribute and color.

Examples found in repository?
examples/demo.rs (line 21)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn attributes(self, attrs: Attributes) -> Self

Set the attributes.

This will not unset any existing attributes.

source

fn bold(self) -> Self

Set the bold attribute.

Examples found in repository?
examples/style.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    let my_style = Style::new().bold().blue();

    println!("{}!", style("Hello").apply(my_style));

    println!(
        "{}",
        style("Rust Language")
            .apply(my_style)
            .link("https://rust-lang.org")
    );
}
More examples
Hide additional examples
examples/demo.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn dim(self) -> Self

Set the dim attribute.

source

fn italic(self) -> Self

Set the italic attribute.

source

fn underline(self) -> Self

Set the underline attribute.

Set the blink attribute.

source

fn reverse(self) -> Self

Set the reverse attribute.

Examples found in repository?
examples/demo.rs (line 10)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn hidden(self) -> Self

Set the hidden attribute.

source

fn strikethrough(self) -> Self

Set the strikethrough attribute.

Examples found in repository?
examples/demo.rs (line 17)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn black(self) -> Self

Set the foreground color to black.

source

fn on_black(self) -> Self

Set the background color to black.

source

fn underline_black(self) -> Self

Set the underline attribute, and set the underline color to black.

source

fn red(self) -> Self

Set the foreground color to red.

Examples found in repository?
examples/demo.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn on_red(self) -> Self

Set the background color to red.

source

fn underline_red(self) -> Self

Set the underline attribute, and set the underline color to red.

source

fn green(self) -> Self

Set the foreground color to green.

Examples found in repository?
examples/demo.rs (line 19)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn on_green(self) -> Self

Set the background color to green.

source

fn underline_green(self) -> Self

Set the underline attribute, and set the underline color to green.

source

fn yellow(self) -> Self

Set the foreground color to yellow.

source

fn on_yellow(self) -> Self

Set the background color to yellow.

source

fn underline_yellow(self) -> Self

Set the underline attribute, and set the underline color to yellow.

source

fn blue(self) -> Self

Set the foreground color to blue.

Examples found in repository?
examples/style.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
fn main() {
    let my_style = Style::new().bold().blue();

    println!("{}!", style("Hello").apply(my_style));

    println!(
        "{}",
        style("Rust Language")
            .apply(my_style)
            .link("https://rust-lang.org")
    );
}
More examples
Hide additional examples
examples/demo.rs (line 8)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn on_blue(self) -> Self

Set the background color to blue.

Examples found in repository?
examples/demo.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn underline_blue(self) -> Self

Set the underline attribute, and set the underline color to blue.

source

fn magenta(self) -> Self

Set the foreground color to magenta.

source

fn on_magenta(self) -> Self

Set the background color to magenta.

source

fn underline_magenta(self) -> Self

Set the underline attribute, and set the underline color to magenta.

source

fn cyan(self) -> Self

Set the foreground color to cyan.

Examples found in repository?
examples/demo.rs (line 9)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
fn main() {
    let hello = style("Hello").bold().red().on_blue();

    println!("{}", lazy_format!("{:b}", 12));

    let world = style_format!("Wor{}ld", style_format!("he{}he", style("haha")).blue())
        .cyan()
        .reverse();

    println!("{hello}, {world}!");

    println!("{:?}", world.style);
    println!("{:?}", world.to_string());

    println!("{}", style("strikethrough").strikethrough());

    println!("{}", link("Google", "https://google.com").bold().green());

    println!("{}", style("Hello").underline_colored(48));
}
source

fn on_cyan(self) -> Self

Set the background color to cyan.

source

fn underline_cyan(self) -> Self

Set the underline attribute, and set the underline color to cyan.

source

fn white(self) -> Self

Set the foreground color to white.

source

fn on_white(self) -> Self

Set the background color to white.

source

fn underline_white(self) -> Self

Set the underline attribute, and set the underline color to white.

source

fn bright_black(self) -> Self

Set the foreground color to bright black.

source

fn on_bright_black(self) -> Self

Set the background color to bright black.

source

fn underline_bright_black(self) -> Self

Set the underline attribute, and set the underline color to bright black.

source

fn bright_red(self) -> Self

Set the foreground color to bright red.

source

fn on_bright_red(self) -> Self

Set the background color to bright red.

source

fn underline_bright_red(self) -> Self

Set the underline attribute, and set the underline color to bright red.

source

fn bright_green(self) -> Self

Set the foreground color to bright green.

source

fn on_bright_green(self) -> Self

Set the background color to bright green.

source

fn underline_bright_green(self) -> Self

Set the underline attribute, and set the underline color to bright green.

source

fn bright_yellow(self) -> Self

Set the foreground color to bright yellow.

source

fn on_bright_yellow(self) -> Self

Set the background color to bright yellow.

source

fn underline_bright_yellow(self) -> Self

Set the underline attribute, and set the underline color to bright yellow.

source

fn bright_blue(self) -> Self

Set the foreground color to bright blue.

source

fn on_bright_blue(self) -> Self

Set the background color to bright blue.

source

fn underline_bright_blue(self) -> Self

Set the underline attribute, and set the underline color to bright blue.

source

fn bright_magenta(self) -> Self

Set the foreground color to bright magenta.

source

fn on_bright_magenta(self) -> Self

Set the background color to bright magenta.

source

fn underline_bright_magenta(self) -> Self

Set the underline attribute, and set the underline color to bright magenta.

source

fn bright_cyan(self) -> Self

Set the foreground color to bright cyan.

source

fn on_bright_cyan(self) -> Self

Set the background color to bright cyan.

source

fn underline_bright_cyan(self) -> Self

Set the underline attribute, and set the underline color to bright cyan.

source

fn bright_white(self) -> Self

Set the foreground color to bright white.

source

fn on_bright_white(self) -> Self

Set the background color to bright white.

source

fn underline_bright_white(self) -> Self

Set the underline attribute, and set the underline color to bright white.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Stylize for Style

source§

impl<T> Stylize for Styled<T>

source§

impl<T, Uri> Stylize for StyledLink<T, Uri>