Expose a way to decompose EcoVec into its components, similar to Vec::into_parts and Vec::from_parts (which are, as of now, nightly only).
This is useful for struct-of-array patterns where multiple vectors always have identical lengths, but might be cloned or mutated separately.
struct SoA {
foo: EcoVec<Foo>,
bar: EcoVec<Foo>,
baz: EcoVec<Baz>,
qux: EcoVec<Qux>,
}
// [usize; 2 * N] size for N items
assert!(std::mem::size_of::<SoA>() == [usize; 8]);
Providing a way to decompose and recompose EcoVec would make such structs significantly smaller:
struct SoA {
foo: EcoVecRaw<Foo>,
bar: EcoVecRaw<Foo>,
baz: EcoVecRaw<Baz>,
qux: EcoVecRaw<Qux>,
len: usize,
}
// [usize; N + 1] size for N items
assert!(std::mem::size_of::<SoA>() == [usize; 5]);
Methods of SoA would recompose the relevant EcoVecRaw (or whatever it ends up being named) with len as necessary to get back an EcoVec.
Expose a way to decompose
EcoVecinto its components, similar toVec::into_partsandVec::from_parts(which are, as of now, nightly only).This is useful for struct-of-array patterns where multiple vectors always have identical lengths, but might be cloned or mutated separately.
Providing a way to decompose and recompose
EcoVecwould make such structs significantly smaller:Methods of
SoAwould recompose the relevantEcoVecRaw(or whatever it ends up being named) withlenas necessary to get back anEcoVec.