Skip to main content

ThemeRole

Struct ThemeRole 

Source
pub struct ThemeRole {
    pub name: &'static str,
    pub node: &'static str,
    pub doc: &'static str,
    pub get: fn(&Theme) -> Color,
    pub set: fn(&mut Theme, Color),
}
Expand description

One colour role in a crate::theme::Theme, with the spelling each binding reads it under and the reading itself.

The same pin ENV_FIELDS is: the palette is one contract, so the roles are written down once and every binding’s reading is generated from this table rather than restated beside it. get is what makes that possible — a binding iterates the rows and asks each one for its colour, so adding a token is one row here and nothing anywhere else. The test below destructures crate::theme::Theme exhaustively, so a field added to it stops the crate compiling until it has a row.

Fields§

§name: &'static str

The Rust field, and the name used everywhere but Node.

§node: &'static str

What Node calls it (camelCase).

§doc: &'static str§get: fn(&Theme) -> Color

This role’s colour out of a theme.

§set: fn(&mut Theme, Color)

The same colour written: what a binding’s theme setter uses, so writing a palette is the table’s business the way reading one is.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.