Trait rustc_errors::Style
source · [−]pub trait Style {
fn render_style_to_color_spec(&self) -> ColorSpec;
}Expand description
‘Style’ is a trait used to specify the user customize ‘XXXStyle’ can be accepted by ‘StyleBuffer’.
It provides the following method render_style_to_color_spec().
render_style_to_color_spec(&self) : render style to terminal color/font configuration.
Required Methods
sourcefn render_style_to_color_spec(&self) -> ColorSpec
fn render_style_to_color_spec(&self) -> ColorSpec
render style to terminal color/font configuration.
Example
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum DummyStyle {
Dummy,
NoStyle,
}
impl Style for DummyStyle {
fn render_style_to_color_spec(&self) -> ColorSpec {
let mut spec = ColorSpec::new();
match self{
// For `DummyStyle::Dummy`, the font is intense and the font color is red.
DummyStyle::Dummy => {
spec.set_fg(Some(Color::Red)).set_intense(true);
}
}
spec
}
}