pub struct ThemeVariants { /* private fields */ }Expand description
Theme variants containing styles for base, light, and dark modes.
Each variant is a map of style names to concrete console::Style values.
Alias definitions are stored separately and resolved at lookup time.
§Resolution Strategy
When looking up a style for a given mode:
- If the style is an alias, follow the chain to find the concrete style
- For concrete styles, check if a mode-specific variant exists
- If yes, return the mode variant (base merged with mode overrides)
- If no, return the base style
§Pruning
During construction, mode variants are only stored if they differ from base. This optimization means:
- Styles with no
light:ordark:sections only have base entries - Styles with overrides have entries in the relevant mode map
Implementations§
Source§impl ThemeVariants
impl ThemeVariants
Sourcepub fn resolve(&self, mode: Option<ColorMode>) -> HashMap<String, StyleValue>
pub fn resolve(&self, mode: Option<ColorMode>) -> HashMap<String, StyleValue>
Resolves styles for the given color mode.
Returns a HashMap<String, StyleValue> where:
- Aliases are preserved as
StyleValue::Alias - Concrete styles are
StyleValue::Concretewith the mode-appropriate style
For light/dark modes, mode-specific styles take precedence over base. For unknown mode (None), only base styles are used.
Trait Implementations§
Source§impl Clone for ThemeVariants
impl Clone for ThemeVariants
Source§fn clone(&self) -> ThemeVariants
fn clone(&self) -> ThemeVariants
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ThemeVariants
impl Debug for ThemeVariants
Auto Trait Implementations§
impl Freeze for ThemeVariants
impl RefUnwindSafe for ThemeVariants
impl Send for ThemeVariants
impl Sync for ThemeVariants
impl Unpin for ThemeVariants
impl UnwindSafe for ThemeVariants
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