Skip to main content

Colorize

Trait Colorize 

Source
pub trait Colorize {
Show 41 methods // Required methods fn bold(&self) -> ColoredString; fn dim(&self) -> ColoredString; fn italic(&self) -> ColoredString; fn underline(&self) -> ColoredString; fn blink(&self) -> ColoredString; fn invert(&self) -> ColoredString; fn strikethrough(&self) -> ColoredString; fn black(&self) -> ColoredString; fn red(&self) -> ColoredString; fn green(&self) -> ColoredString; fn yellow(&self) -> ColoredString; fn blue(&self) -> ColoredString; fn magenta(&self) -> ColoredString; fn cyan(&self) -> ColoredString; fn white(&self) -> ColoredString; fn rgb(&self, r: u8, g: u8, b: u8) -> ColoredString; fn on_black(&self) -> ColoredString; fn on_red(&self) -> ColoredString; fn on_green(&self) -> ColoredString; fn on_yellow(&self) -> ColoredString; fn on_blue(&self) -> ColoredString; fn on_magenta(&self) -> ColoredString; fn on_cyan(&self) -> ColoredString; fn on_white(&self) -> ColoredString; fn on_rgb(&self, r: u8, g: u8, b: u8) -> ColoredString; fn bright_black(&self) -> ColoredString; fn bright_red(&self) -> ColoredString; fn bright_green(&self) -> ColoredString; fn bright_yellow(&self) -> ColoredString; fn bright_blue(&self) -> ColoredString; fn bright_magenta(&self) -> ColoredString; fn bright_cyan(&self) -> ColoredString; fn bright_white(&self) -> ColoredString; fn on_bright_black(&self) -> ColoredString; fn on_bright_red(&self) -> ColoredString; fn on_bright_green(&self) -> ColoredString; fn on_bright_yellow(&self) -> ColoredString; fn on_bright_blue(&self) -> ColoredString; fn on_bright_magenta(&self) -> ColoredString; fn on_bright_cyan(&self) -> ColoredString; fn on_bright_white(&self) -> ColoredString;
}
Expand description

Extension trait for applying ANSI styling to strings

This trait is implemented for any type that implements AsRef<str>, including &str and String.

§Examples

use tinycolor::Colorize;
 
// Works with string literals
println!("{}", "Warning!".red().bold().invert());
 
// Works with owned strings
println!("{}", String::from("Hello").blue().italic());
 
// Can chain multiple effects
println!("{}", "text".green().bold().underline().strikethrough());

§Feature Flags

  • color-ext: Enables additional methods: rapid_blink, conceal, fraktur

Required Methods§

Source

fn bold(&self) -> ColoredString

Source

fn dim(&self) -> ColoredString

Source

fn italic(&self) -> ColoredString

Source

fn underline(&self) -> ColoredString

Source

fn invert(&self) -> ColoredString

Source

fn strikethrough(&self) -> ColoredString

Source

fn black(&self) -> ColoredString

Source

fn red(&self) -> ColoredString

Source

fn green(&self) -> ColoredString

Source

fn yellow(&self) -> ColoredString

Source

fn blue(&self) -> ColoredString

Source

fn magenta(&self) -> ColoredString

Source

fn cyan(&self) -> ColoredString

Source

fn white(&self) -> ColoredString

Source

fn rgb(&self, r: u8, g: u8, b: u8) -> ColoredString

Source

fn on_black(&self) -> ColoredString

Source

fn on_red(&self) -> ColoredString

Source

fn on_green(&self) -> ColoredString

Source

fn on_yellow(&self) -> ColoredString

Source

fn on_blue(&self) -> ColoredString

Source

fn on_magenta(&self) -> ColoredString

Source

fn on_cyan(&self) -> ColoredString

Source

fn on_white(&self) -> ColoredString

Source

fn on_rgb(&self, r: u8, g: u8, b: u8) -> ColoredString

Source

fn bright_black(&self) -> ColoredString

Source

fn bright_red(&self) -> ColoredString

Source

fn bright_green(&self) -> ColoredString

Source

fn bright_yellow(&self) -> ColoredString

Source

fn bright_blue(&self) -> ColoredString

Source

fn bright_magenta(&self) -> ColoredString

Source

fn bright_cyan(&self) -> ColoredString

Source

fn bright_white(&self) -> ColoredString

Source

fn on_bright_black(&self) -> ColoredString

Source

fn on_bright_red(&self) -> ColoredString

Source

fn on_bright_green(&self) -> ColoredString

Source

fn on_bright_yellow(&self) -> ColoredString

Source

fn on_bright_blue(&self) -> ColoredString

Source

fn on_bright_magenta(&self) -> ColoredString

Source

fn on_bright_cyan(&self) -> ColoredString

Source

fn on_bright_white(&self) -> ColoredString

Implementors§