[][src]Function crossterm::style

pub fn style<'a, D>(val: D) -> StyledObject<D> where
    D: 'a + Display

This could be used to style a type who is implementing Display with colors and attributes.

Example

// get an styled object which could be painted to the terminal.
let styled_object = style("Some Blue colored text on black background")
    .with(Color::Blue)
    .on(Color::Black);

// print the styled font * times to the current screen.
for i in 1..10
{
    println!("{}", styled_object);
}

Important Remark

  • Please checkout the documentation for Colorizer or Styler. Those types will make it a bit easier to style a string.