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 strThe Rust field, and the name used everywhere but Node.
node: &'static strWhat Node calls it (camelCase).
doc: &'static str§get: fn(&Theme) -> ColorThis 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§
impl Freeze for ThemeRole
impl RefUnwindSafe for ThemeRole
impl Send for ThemeRole
impl Sync for ThemeRole
impl Unpin for ThemeRole
impl UnsafeUnpin for ThemeRole
impl UnwindSafe for ThemeRole
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.