Trait erg_common::style::Stylize

source ·
pub trait Stylize {
    type Output;

    // Required methods
    fn stylize(self) -> Self::Output;
    fn with_color(self, color: Color) -> Self::Output;
    fn with_attr(self, attribute: Attribute) -> Self::Output;
    fn with_color_and_attr(
        self,
        color: Color,
        attribute: Attribute
    ) -> Self::Output;
}
Expand description
let new = "hello".stylize();
let old = StyledStr::new("hello", None, None);
assert_eq!(new, old);
let new = "hello".to_string().with_color_and_attr(THEME.colors.warning, Attribute::Bold);
let old = StyledString::new("hello", Some(THEME.colors.warning), Some(Attribute::Bold));
assert_eq!(new, old);

Required Associated Types§

Required Methods§

source

fn stylize(self) -> Self::Output

source

fn with_color(self, color: Color) -> Self::Output

source

fn with_attr(self, attribute: Attribute) -> Self::Output

source

fn with_color_and_attr(self, color: Color, attribute: Attribute) -> Self::Output

Implementations on Foreign Types§

source§

impl Stylize for String

source§

impl<'a> Stylize for &'a str

§

type Output = StyledStr<'a>

source§

fn stylize(self) -> StyledStr<'a>

source§

fn with_color(self, color: Color) -> StyledStr<'a>

source§

fn with_attr(self, attribute: Attribute) -> StyledStr<'a>

source§

fn with_color_and_attr( self, color: Color, attribute: Attribute ) -> StyledStr<'a>

Implementors§