Skip to main content

ColorSet

Trait ColorSet 

Source
pub trait ColorSet: Copy + 'static {
    const ALL: &'static [Self];

    // Required methods
    fn name(self) -> &'static str;
    fn index(self) -> usize;

    // Provided method
    fn engine_name(color: EngineColor) -> &'static str { ... }
}
Expand description

The colors a game’s code draws with, by name: usually an enum, whose every name its palette must have.

Required Associated Constants§

Source

const ALL: &'static [Self]

Every color of the set, each at its index.

Required Methods§

Source

fn name(self) -> &'static str

The color’s name in the palette.

Source

fn index(self) -> usize

Where the color is in ALL.

Provided Methods§

Source

fn engine_name(color: EngineColor) -> &'static str

The palette’s name for an engine color. By default its own (EngineColor::name), so the palette must have text, panel and the rest; a game whose palette calls them otherwise says so here.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ColorSet for EngineColor

The engine’s own colors as a set: for a palette with nothing more than the engine’s names.

Source§

const ALL: &'static [Self] = EngineColor::ALL