[−][src]Crate flatvec
An indirection-collapsing container that generalizes nested.
A FlatVec can be used like a Vec<String> or Vec<Vec<u8>>, but with a maximum of 2 heap
allocations instead of n + 1.
Insertion into and retrieval from a FlatVec is mediated by two traits, IntoFlat and
FromFlat, which are both parameterized on two types. The simplest way to use this crate is to
impl IntoFlat<T> for T and impl FromFlat<'_, T> for T for some type T in your crate.
But in general, the interface is impl IntoFlat<Flattened> for Source and impl FromFlat<'a, Dest> for Flattened. An owned or borrowed type Source is effectively serialized into a
FlatVec, then an instance of a type that defines its ability to be constructed from a
FlatVec<Flattened> can be produced, possibly borrowing the data in the FlatVec to return a
specialized type that does not copy the data stored in the FlatVec to present a view of it.
This interface is extremely powerful and essentially amounts to in-memory serialization and
conversion all in one. For example, a user can construct a FlatVec that compreses all of its
elements with gzip. I'm not saying that's a good idea. But you can.
Structs
| FlatVec | An indirection-collapsing container with minimal allocation |
| Storage | A wrapper over the innards of a |
Traits
| FromFlat | Implement |
| IntoFlat | Implement |