Expose unsafe `into_parts` and `from_parts` functions
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 320
- Forks
- 32
- Avg merge
- 4d 13h
- Merged PRs (30d)
- 1
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the EcoVec implementation and the linked Vec::into_parts and Vec::from_parts documentation. Determine how EcoVec's components can be safely decomposed and recomposed for the struct-of-array example. Done means the requested unsafe APIs are exposed with behavior that supports storing raw components and restoring EcoVec values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100