-
-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels