Expand description
This crate supplies the Recast and Recaster traits. These are intended
for the translation of arena indexes like those in the triple_arena crate,
however they can be used for any purpose of one-to-one recasting of values.
A Recaster is the storage type defining the old-to-new mapping that some
domain remapping operation produces, and Recast is what walks a structure
and applies that mapping to every Item it finds.
Recast is implemented here for the primitive integer types (including the
NonZero variants), bool, char, f32, f64, and for many wrappers and
collections that forward to the impls of whatever they contain. Recaster
is implemented for the standard collection types HashMap and BTreeMap,
which can act directly as an Item to Item mapping. Note that for the
Recast (not their Recaster) implementations of HashMap and BTreeMap,
only the values of the maps are recast and never the keys, because
changing a key in place would break the ordering or hashing invariant of the
map. The same reasoning is why there are no impls for set types like
HashSet. Such a collection has to be drained into a new one instead, with
each key or element recast on the way. The same reasoning applies to
downstream maps like triple_arena::Arena.
Note that there are “alloc” and “std” feature flags that can be turned off