Struct mimi::Style

source ·
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§

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.

An ANSI control code sequence that will cause text to be formatted in the given style. This assumes that the old state has no foreground color, no background color, etc.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.