#[non_exhaustive]pub struct Style {
pub foreground: Color,
pub background: Color,
pub intensity: Intensity,
}
Expand description
A style to render text with, setting the foreground and background colors, along with intensity.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.foreground: Color
The text foreground color
background: Color
The text background color
intensity: Intensity
The text intensity
Implementations§
Source§impl Style
impl Style
Sourcepub fn with(self, adj: impl Restyle) -> Style
pub fn with(self, adj: impl Restyle) -> Style
Apply a modification to this style, returning the result.
use stylish::{Intensity, Style};
let mut expected = Style::default();
expected.intensity = Intensity::Faint;
assert_eq!(Style::default().with(Intensity::Faint), expected);
Sourcepub fn diff_from(self, original: Style) -> StyleDiff
pub fn diff_from(self, original: Style) -> StyleDiff
Find the changes from the original
style that would result in this
style.
This can be useful for writers like ansi
that are stateful, finding
the minimal state that must be changed between the current output
style and the new style.
use stylish::{Color, Foreground, Style, StyleDiff};
let original = Style::default();
let updated = original.with(Foreground(Color::Cyan));
assert!(matches!(
updated.diff_from(original),
StyleDiff {
foreground: Some(Color::Cyan),
background: None,
intensity: None,
..
}
));
Trait Implementations§
impl Copy for Style
impl Eq for Style
impl StructuralPartialEq for Style
Auto Trait Implementations§
impl Freeze for Style
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more