Space cost of a im::Vector with a single item:

Quoting: im::Vector - Rust

Because of the head/tail chunking technique, until you push a number of items above double the tree's branching factor (that's self.len() = 2 × k (where k = 64) = 128) on either side, the data structure is still just a handful of arrays, not yet an RRB tree, so you'll see performance and memory characteristics similar to Vec or VecDeque .

This means that the structure always preallocates four chunks of size k ( k being the tree's branching factor), equivalent to a Vec with an initial capacity of 256. Beyond that, it will allocate tree nodes of capacity k as needed.

In addition, vectors start out as single chunks, and only expand into the full data structure once you go past the chunk size. This makes them perform identically to Vec at small sizes.


Does this mean that an im::Vector with a single item uses 256 * sizeof(T) space? (with one unit initialized, and the other 255 uninitialized) ?