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.