Struct stylish_style::Style
source · #[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: ColorThe text foreground color
background: ColorThe text background color
intensity: IntensityThe text intensity
Implementations§
source§impl Style
impl Style
sourcepub fn with(self, adj: impl Restyle) -> Self
pub fn with(self, adj: impl Restyle) -> Self
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§
source§impl PartialEq for Style
impl PartialEq for Style
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)