Expand description
SingleVec
is Vec
-like container type optimized for storing a single item.
0 or 1 items are stored internally as a standard Option
-
which can be kept on the stack -
but falls back to a standard Vec
for multiple items -
which are stored on the heap.
Although SingleVec
shares many of the same traits and methods as Vec
,
it also shares many of the same methods as Option
and Iterator
where appropriate.
Since only a single optional item is intended to be the common case,
those methods can avoid iteration altogether.
§Other Features
serde
providesSerialize
andDeserialize
support, provided that the inner type also has the same implementation.
Enums§
- Either
Iterator - An iterator which can be one of two possible variants but iterate over the same type.
- Single
Vec - A
Vec
-like type optimized for storing 0 or 1 items.