Expand description
This crate provides the Finite
trait for use with types with a small number of values
(typically, but not exclusively enum
s). Deriving this trait enables several useful
applications:
Macros
Implements helper traits for a concrete (i.e. non-parameteric) type that implements Finite
.
Structs
A complete mapping from keys of type K
to values of type V
, implemented using an array
indexed by Finite::index_of
of the key.
A set of values of type T
, implemented using a bitmap.
A compressed representation of a value of type T
, implemented by storing its index
according Finite::index_of
using the smallest integer type possible.
An iterator over all of the values of a Finite
type.
Traits
Provides the number of values for a type, as well as a 1-to-1 mapping between the subset of
integers [0 .. N) and those values. The ordering of integers in this mapping is homomorphic to
the ordering of values according to Ord
(i.e. T::index_of(a) < T::index_of(b)
iff
a < b
).
A set of values of type T
.
Functions
Gets a compressed representation of the given value.