Introducing tinyset, a create with size optimized sets.
I’ve been working on developing an improved set type, and now have something that others may find useful. TinySet is a variant of HashSet which is optimized for the case of a set of small keys such as integers. In this case hashing is fast (with fnv), and storing both keys and hashes of keys is a waste of space. In addition, to save space we specialize on the case where you can define a key that is invalid, typically the maximum value of the integral type. With these tweaks, which I define in the HasInvalid trait, we can have a set type that is about as fast as fnv::HashMap, but takes a lot less memory.
For u32 keys, we have three times less memory used for large sets, and about 20 times less memory used for sets of up to 4 elements, with no heap allocation for sets in that size range.
The API is not yet complete, and I will welcome contributions, feature requests, or bug reports!