Expand description
Hashing and other caching utilities for Color types.
In this crate, colors are implemented using f32
.
This means that color types aren’t Hash
and Eq
for good reasons:
- Equality on these types is not reflexive (consider NaN).
- Certain values have two representations (
-0
and+0
are both zero).
However, it is still useful to create caches which key off these values. These are caches which don’t have any semantic meaning, but instead are used to avoid redundant calculations or storage.
Color supports creating these caches by using CacheKey<T>
as the key in
your cache.
T
is the key type (i.e. a color) which you want to use as the key.
This T
must implement both BitHash
and BitEq
, which are
versions of the standard Hash
and Eq
traits which support implementations
for floating point numbers which might be unexpected outside of a caching context.
Structs§
- Cache
Key - A key usable in a hashmap to compare the bit representation types containing colors.