Comments (6)
Hm for the single length thing perhaps just make the storage generic and use a HList?
I really don't see how a HList would help here, could you clarify?
EDIT: moved the discussion to #19 (comment)
I'd love to talk about project reorganization to code this features more easier (the more advanced the features the more I tend to hurt myself with it).
I'm open to changes in this crate code organization: while none of the code is very complex, it can be a bit daunting to make changes, and the compiler error messages are not very helpful when you make a typo/miss a bound somewhere. Please open an issue with your proposition!
from soa-derive.
Yes, that's something that would be nice to implement, and should not be too hard. Unfortunately, I have very limited time to work on this crate, so this would be a good candidate for an external contribution!
It should only be a matter of storing the generic parameters and bounds in the Input
struct; and then parametrize the generated structs (slice, mut slice, reference, mut reference, pointer, mut pointer, ...) by the same generic parameters and bounds. The impl
blocks should also be parametrized by the same generics parameters & bounds.
from soa-derive.
My god this looks like so much work...
from soa-derive.
To be honest I'd love to work on it. Unfortunately right now I don't really have the time for it (and single length would come first anyways). I'd love to talk about project reorganization to code this features more easier (the more advanced the features the more I tend to hurt myself with it).
from soa-derive.
Hm for the single length thing perhaps just make the storage generic and use a HList?
from soa-derive.
So for using a HList, your #[derive(StructOfArray)]
would effectively create this:
struct Foo {
x: i32,
y: String,
}
impl From<HList<String, HList<i32, HNil>> for Foo
impl From<Foo> for HList<String, HList<i32, HNil>>
then the vector type would simply be something like this:
struct SOAStorage<T: Into<HList...> + From<HList...>> {
vec: Vec<T::Head>
next: SOAStorage<T::Tail>
}
(Or something like this, this doesn't compile but you probably get the point right?)
But this way you only need to implement a single trait and then just use SOAStorage<Foo>
for all other cases. Also supports having custom storages like one that stores length once.
from soa-derive.
Related Issues (20)
- Allow explicit name generation HOT 1
- Use one length and capacity variable for whole struct HOT 23
- Update versions of `syn` and `quote` HOT 3
- Provide FromIterator implementation HOT 3
- Use trait to link the origin struct to generated soa struct HOT 3
- Add access methods HOT 3
- Allow to nest structs of arrays HOT 9
- Nitpick: doc for generated vec-like methods have extra spaces HOT 1
- #[soa_attr] on field
- #[serde(skip)] cause struct of array containing different length of field HOT 4
- Const array SoA variant HOT 2
- Cannot find trait `SoAIter` in crate `soa_derive` HOT 3
- Sorting methods for Slice variant HOT 2
- Derive std::iter::Extend HOT 1
- Is it possible to avoid duplicate capacity and size fields? HOT 1
- How do you go from `MyTypeRef` to `MyType` ? HOT 6
- How to set #[pyclass] attribute for soa-derived struct? HOT 2
- cannot move out of type `CheeseVec`, which implements the `Drop` trait HOT 2
- Generics programming using soa-derive HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from soa-derive.