§compact-vec
A CompactVec is a Vec<u32>-compatible container that automatically stores
unsigned integers in the smallest possible byte width (1, 2, 3, or 4 bytes per
element), upgrading in place when a newly pushed value exceeds the current
maximum representable value.
§Quick example
use compact_vec::CompactVec;
let mut cv = CompactVec::new();
cv.push(0); cv.push(255); cv.push(256); assert_eq!(cv.width_bits(), 16);
assert_eq!(cv.get(0), Some(0));
assert_eq!(cv.get(2), Some(256));
§Memory savings
| Value range | Width | Savings vs Vec<u32> |
| 0 – 255 | 8 bit | 75 % |
| 256 – 65 535 | 16 bit | 50 % |
| 65 536 – 16 M | 24 bit | 25 % |
| 16 M – 4 G | 32 bit | 0 % |
§Feature flags
| Flag | Effect |
serde | Implements Serialize / Deserialize |