Expand description

tinyset contains a few collections that are optimized to scale in size well for small numbers of elements, while still scaling well in time (and size) for numbers of elements. We now have just a few types that you might care for.

  1. Set64 is a set for types that are 64 bits in size or less and are Copy, intended for essentially integer types. This is our most efficient type, since it can store small sets with just the size of one pointer, with no heap storage.

  2. SetU64 just holds u64 items, and is the internal storage of Set64.

  3. SetU32 just holds u32 items, and uses a bit less memory than SetU64.

  4. SetUsize holds usize items, and uses either SetU64 or SetU32 internally.

All of these set types will do no heap allocation for small sets of small elements. Small sets occupy the same space as a single pointer, typically 64 bits. In these 64 bits (or 32 bits), you can store up to seven elements if the elements are sufficiently small and not too widely spaced. For larger numbers and more widely spaced numbers, you can store progressively fewer elements without doing a heap allocation. When it does require a heap allocation, tinyset is still far more compact than a HashSet, particularly when the elements themselves are small.

These sets all differ from the standard sets in that they iterate over items rather than references to items, because they do not store values directly in a way that can be referenced. All of the type-specific sets further differ in that remove and contains accept values rather than references.


use tinyset::Set64;
let mut s: Set64<usize> = Set64::new();


pub use setusize::SetUsize;
pub use setu32::SetU32;
pub use setu64::SetU64;
pub use crate::set64::Fits64;
pub use crate::set64::Set64;


A set that is compact in size.
This is a crate for the tiniest sets ever.
This is a crate for the tiniest sets ever.
A set that is compact in size.