GithubHelp home page GithubHelp logo

Comments (3)

Luthaf avatar Luthaf commented on August 31, 2024 1

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.

Alexandre425 avatar Alexandre425 commented on August 31, 2024

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.

Alexandre425 avatar Alexandre425 commented on August 31, 2024

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)

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.