Giter Site home page Giter Site logo

Does not support generics. about soa-derive HOT 6 OPEN

lumol-org avatar lumol-org commented on July 26, 2024 3
Does not support generics.

from soa-derive.

Comments (6)

Luthaf avatar Luthaf commented on July 26, 2024 1

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.

Luthaf avatar Luthaf commented on July 26, 2024

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.

iMplode-nZ avatar iMplode-nZ commented on July 26, 2024

My god this looks like so much work...

from soa-derive.

mangelats avatar mangelats commented on July 26, 2024

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.

iMplode-nZ avatar iMplode-nZ commented on July 26, 2024

Hm for the single length thing perhaps just make the storage generic and use a HList?

from soa-derive.

iMplode-nZ avatar iMplode-nZ commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.