Macro stilo::stylize

source ·
macro_rules! stylize {
    (
        $text: literal
        $(, $arg: expr )* $(,)?
    ) => { ... };
    (
        $text: literal :
        $( if $condition: expr )?
        $(, $arg: expr )* $(,)?
    ) => { ... };
    (
        $text: literal :
        $style: block
        $( if $condition: expr )?
        $(, $arg: expr )* $(,)?
    ) => { ... };
    (
        $text: literal :
        $( $color: ident )?
        $( + $decor: ident )*
        $( if $condition: expr )?
        $(, $arg: expr )* $(,)?
    ) => { ... };
}
Expand description

Creates a Style struct and formats text.

Similar to the stylize function.

Examples

// Red
println!("{}", stylize!("Hello": Red));

// Red, italic, and bold
println!("{}", stylize!("Hello": Red + italic + bold));

// Default color, italic and bold
println!("{}", stylize!("Hello": +i+b));

// Format string
let world = "World!";
println!("{}", stylize!("Hello {}": Green + i+b, world));