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§
sourcefn underline_colored(self, color: impl Into<Color>) -> Self
fn underline_colored(self, color: impl Into<Color>) -> Self
Set the underline attribute and color.
Examples found in repository?
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));
}sourcefn attributes(self, attrs: Attributes) -> Self
fn attributes(self, attrs: Attributes) -> Self
Set the attributes.
This will not unset any existing attributes.
sourcefn bold(self) -> Self
fn bold(self) -> Self
Set the bold attribute.
Examples found in repository?
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
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));
}sourcefn reverse(self) -> Self
fn reverse(self) -> Self
Set the reverse attribute.
Examples found in repository?
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));
}Set the hidden attribute.
sourcefn strikethrough(self) -> Self
fn strikethrough(self) -> Self
Set the strikethrough attribute.
Examples found in repository?
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));
}sourcefn underline_black(self) -> Self
fn underline_black(self) -> Self
Set the underline attribute, and set the underline color to black.
sourcefn red(self) -> Self
fn red(self) -> Self
Set the foreground color to red.
Examples found in repository?
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));
}sourcefn underline_red(self) -> Self
fn underline_red(self) -> Self
Set the underline attribute, and set the underline color to red.
sourcefn green(self) -> Self
fn green(self) -> Self
Set the foreground color to green.
Examples found in repository?
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));
}sourcefn underline_green(self) -> Self
fn underline_green(self) -> Self
Set the underline attribute, and set the underline color to green.
sourcefn underline_yellow(self) -> Self
fn underline_yellow(self) -> Self
Set the underline attribute, and set the underline color to yellow.
sourcefn blue(self) -> Self
fn blue(self) -> Self
Set the foreground color to blue.
Examples found in repository?
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
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));
}sourcefn on_blue(self) -> Self
fn on_blue(self) -> Self
Set the background color to blue.
Examples found in repository?
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));
}sourcefn underline_blue(self) -> Self
fn underline_blue(self) -> Self
Set the underline attribute, and set the underline color to blue.
sourcefn on_magenta(self) -> Self
fn on_magenta(self) -> Self
Set the background color to magenta.
sourcefn underline_magenta(self) -> Self
fn underline_magenta(self) -> Self
Set the underline attribute, and set the underline color to magenta.
sourcefn cyan(self) -> Self
fn cyan(self) -> Self
Set the foreground color to cyan.
Examples found in repository?
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));
}sourcefn underline_cyan(self) -> Self
fn underline_cyan(self) -> Self
Set the underline attribute, and set the underline color to cyan.
sourcefn underline_white(self) -> Self
fn underline_white(self) -> Self
Set the underline attribute, and set the underline color to white.
sourcefn bright_black(self) -> Self
fn bright_black(self) -> Self
Set the foreground color to bright black.
sourcefn on_bright_black(self) -> Self
fn on_bright_black(self) -> Self
Set the background color to bright black.
sourcefn underline_bright_black(self) -> Self
fn underline_bright_black(self) -> Self
Set the underline attribute, and set the underline color to bright black.
sourcefn bright_red(self) -> Self
fn bright_red(self) -> Self
Set the foreground color to bright red.
sourcefn on_bright_red(self) -> Self
fn on_bright_red(self) -> Self
Set the background color to bright red.
sourcefn underline_bright_red(self) -> Self
fn underline_bright_red(self) -> Self
Set the underline attribute, and set the underline color to bright red.
sourcefn bright_green(self) -> Self
fn bright_green(self) -> Self
Set the foreground color to bright green.
sourcefn on_bright_green(self) -> Self
fn on_bright_green(self) -> Self
Set the background color to bright green.
sourcefn underline_bright_green(self) -> Self
fn underline_bright_green(self) -> Self
Set the underline attribute, and set the underline color to bright green.
sourcefn bright_yellow(self) -> Self
fn bright_yellow(self) -> Self
Set the foreground color to bright yellow.
sourcefn on_bright_yellow(self) -> Self
fn on_bright_yellow(self) -> Self
Set the background color to bright yellow.
sourcefn underline_bright_yellow(self) -> Self
fn underline_bright_yellow(self) -> Self
Set the underline attribute, and set the underline color to bright yellow.
sourcefn bright_blue(self) -> Self
fn bright_blue(self) -> Self
Set the foreground color to bright blue.
sourcefn on_bright_blue(self) -> Self
fn on_bright_blue(self) -> Self
Set the background color to bright blue.
sourcefn underline_bright_blue(self) -> Self
fn underline_bright_blue(self) -> Self
Set the underline attribute, and set the underline color to bright blue.
sourcefn bright_magenta(self) -> Self
fn bright_magenta(self) -> Self
Set the foreground color to bright magenta.
sourcefn on_bright_magenta(self) -> Self
fn on_bright_magenta(self) -> Self
Set the background color to bright magenta.
sourcefn underline_bright_magenta(self) -> Self
fn underline_bright_magenta(self) -> Self
Set the underline attribute, and set the underline color to bright magenta.
sourcefn bright_cyan(self) -> Self
fn bright_cyan(self) -> Self
Set the foreground color to bright cyan.
sourcefn on_bright_cyan(self) -> Self
fn on_bright_cyan(self) -> Self
Set the background color to bright cyan.
sourcefn underline_bright_cyan(self) -> Self
fn underline_bright_cyan(self) -> Self
Set the underline attribute, and set the underline color to bright cyan.
sourcefn bright_white(self) -> Self
fn bright_white(self) -> Self
Set the foreground color to bright white.
sourcefn on_bright_white(self) -> Self
fn on_bright_white(self) -> Self
Set the background color to bright white.
sourcefn underline_bright_white(self) -> Self
fn underline_bright_white(self) -> Self
Set the underline attribute, and set the underline color to bright white.