Module smallmap::space

source ·
Expand description

Space-efficient small maps and sets

To make an entirely space efficient Map (i.e. size of each page is 256 bytes, there is never more than 1 page), the following must be true:

  • The key must be 8 bits wide and subject to the null pointer optimisation
  • The value must be a ZST.

This leaves pretty much only std::num::NonZeroU8 and std::num::NonZeroI8 as entirely space-efficient key candidates. The restriction on values also means the only entirely space-efficient smallmaps are sets, enable to encode only if a key is present, with no extra information. (See std::collections::HashSet).

Type Aliases