Function conciliator::style::set_palette

source ·
pub unsafe fn set_palette(new: Palette)
Expand description

Overwrite the global static color Palette

§Safety

In a multi-threaded context this is technically undefined behavior, because another thread might be reading from (or writing to) it at the same time. Still, there’s nothing to go (catastrophically) wrong: the Palette is simply being overwritten in-place – even if another read or write was interleaved with this, there’s no way an invalid ColorCode could be produced since each of them fits into a single byte.

It is, however, plausible that overlapping reads and writes produce a novel combination of ColorCodes that is a mash-up of (the) old and new Palettes. This may be undesired, but it shouldn’t violate memory safety.

With all that said, it is completely fine to call this function in a single-threaded application. Ideally, it would be called once, at the beginning, before calling conciliator::init.