Trait Style

Source
pub trait Style: Display {
    // Provided methods
    fn bold(&self) -> String { ... }
    fn dim(&self) -> String { ... }
    fn italic(&self) -> String { ... }
    fn underline(&self) -> String { ... }
    fn blink(&self) -> String { ... }
    fn reverse(&self) -> String { ... }
    fn hidden(&self) -> String { ... }
    fn striketrough(&self) -> String { ... }
}

Provided Methods§

Source

fn bold(&self) -> String

Applies bold style to the string.

Examples found in repository?
examples/strings.rs (line 11)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn dim(&self) -> String

Dims the color of the string.

Examples found in repository?
examples/strings.rs (line 12)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn italic(&self) -> String

Applies italic style to the string.

Examples found in repository?
examples/strings.rs (line 13)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn underline(&self) -> String

Underlines the string.

Examples found in repository?
examples/strings.rs (line 14)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}

Makes the content of the string blink.

Examples found in repository?
examples/strings.rs (line 19)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn reverse(&self) -> String

Reverses the foreground and background colors of the string.

Examples found in repository?
examples/strings.rs (line 20)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn hidden(&self) -> String

Hides the content of the string with the background color.

Examples found in repository?
examples/strings.rs (line 21)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}
Source

fn striketrough(&self) -> String

Strikes through the content of the string.

Examples found in repository?
examples/strings.rs (line 22)
3fn main() {
4    println!(
5        "{}",
6        "This is yellow text on a cyan background!"
7            .color(Color::Yellow)
8            .background(Color::Cyan)
9    );
10
11    println!("{}", "This is bold text!".bold().color(Color::Red));
12    println!("{}", "This is dim text!".dim());
13    println!("{}", "This is italic text!".italic());
14    println!("{}", "This is underlined text!".underline());
15    println!(
16        "{}",
17        "This is a styled message!".bold().italic().underline()
18    );
19    println!("{}", "Blinking text!".blink());
20    println!("{}", "Reversed background!".reverse());
21    println!("{}", "Hidden text!".hidden());
22    println!("{}", "Something wrong.".striketrough());
23
24    println!("{}", "I like cyan".color(Color::BrightCyan));
25}

Implementations on Foreign Types§

Source§

impl Style for str

Source§

impl Style for String

Implementors§