pub struct Style {
pub foreground: Option<Color>,
pub background: Option<Color>,
pub modifiers: HashSet<Modifier>,
}
Expand description
Describes the foreground color, background color, and any additional modifications (inverse, bold, etc).
Fields§
§foreground: Option<Color>
The color used to render the text. If None
, uses whatever the
terminal’s default color is.
background: Option<Color>
The color used to render the background. If None
, uses whatever the
terminal’s default color is.
modifiers: HashSet<Modifier>
Any extra formatting information, such as bold/italic.
Implementations§
source§impl Style
impl Style
sourcepub fn combine(&self, other: &Style) -> Style
pub fn combine(&self, other: &Style) -> Style
Combines the two styles. If other
has a foreground color specified,
the combined style uses that color; else, self
’s color is used. The
same logic applies to background colors. The modifier sets are unioned.
This operation is associative (i.e., foo.combine(bar.combine(baz)) == (foo.combine(bar)).combine(baz)
but not commutative (i.e.,
foo.combine(bar) != bar.combine(foo)
), and
foo.combine(Style::default()) == Style::default().combine(foo) == foo
.
If you’re a math nerd, Style::combine
forms a monoid.