Comments (3)
Hey! I never used this code in a generic context, so I'm not sure if there is a workaround for the lack of associated methods.
StructOfArray::Type
was added by @mikialex who wanted to do something similar in #24/#25. Maybe they have more idea about how to achieve this?
from soa-derive.
I made some progress in realizing the type refers to the derived CheeseVec
, and so my implementation now looks like this:
pub struct SparseSet<T: StructOfArray> {
dense: Vec<EntID>,
sparse: Vec<u32>,
data: <T as StructOfArray>::Type,
}
However, this still will not allow me to have generic implementations, as the following errors:
pub fn new() -> Self {
Self {
dense: Vec::new(),
sparse: Vec::new(),
data: <T as StructOfArray>::Type::new(),
}
}
error[E0599]: no function or associated item named
new
found for associated type<T as StructOfArray>::Type
in the current scope
Do I have any alternatives? Any trait that implements the methods I need, so that I can have generic implementations?
from soa-derive.
I see, I did find that PR, that commit was what helped me figure out part of it. If @mikialex can let me know if they've ever done generic implementations using their contribution, that would be really helpful. Otherwise I suppose I will look for an alternative, macros perhaps.
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
- Does not support generics. HOT 6
- #[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
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.