Expand description
A bounded small-vector with a u8-sized header and an optional inline
buffer. Backs both the List variant of crate::AutoMap and, with
INLINE = 0, TaskStorage’s lazy-fields collection.
This is functionally a SmallVec<[T; INLINE]> that is bounded at MAX
elements, but with a much smaller header:
SmallVecstores ausizelength and, in its spilled representation, a heap pointer plus ausizecapacity. Threeusizes of header.- Because the element count never exceeds
MAX(<= 254), both the length and the capacity fit in au8.TinyVecstoreslen: NonZeroU8andcap: u8— two bytes of header — and overlaps the inline array with the heap pointer in a union.
The length is stored as NonZeroU8 (holding actual_len + 1) so that 0
is a forbidden bit pattern. That niche lets the enclosing AutoMap enum
fold its List/Map discriminant in for free — no separate tag word. For
example AutoMap<TaskId, (), _, 3> (a NonZero-keyed set) shrinks from 32
bytes with SmallVec to 24, and AutoMap<TaskId, (), _, 0> to 16.
§Type parameters
INLINE— elements stored inline in the struct before spilling to the heap.INLINE = 0(the default) is a pure heap vector with a 2-byte header — 16 B on 64-bit, vs 24 B forVec.MAX— hard cap on the element count. Defaults toMAX_LIST_SIZE. Pushing pastMAXpanics; growth doubles until it would exceedMAX, then caps at exactlyMAX.
§Representation
cap == INLINE: elements live inline indata.inline[..len].cap > INLINE: elements live on the heap atdata.heap[..len], in an allocation ofcapelements. Only reachable once more thanINLINEelements are inserted; capped atMAX.
Structs§
- Drain
- Draining iterator returned by
TinyVec::drain. - Into
Iter - By-value iterator returned by
TinyVec::into_iter. - TinyVec
- Bounded small-vector with an optional inline buffer; see the module docs.