Giter Club home page Giter Club logo

Comments (8)

KodrAus avatar KodrAus commented on July 19, 2024 1

This might work best as an independent 'flag' somewhere in the attribute, since if you specify #[auto_impl(&, Box)] you probably want both to be implemented for dyn Trait. Maybe even just something like:

#[auto_impl(dyn, Box, &, &mut)]
pub trait Trait {}

So you don't have different items to bring into scope. It's a bit of a semantic overloading of what goes in the attribute, but I think it's a simple enough concept that it shouldn't be an issue. What do you think? I'm guessing any support is going to be welcomed 😄

from auto_impl.

LukasKalbertodt avatar LukasKalbertodt commented on July 19, 2024 1

@daniel5151 As you can see from this thread, there are a few open questions (mainly regarding how to specify this). To be honest, I don't use auto_impl anymore and have kind of lost interest in the project, so I will not implement this. If you want to see this, you probably have to implement it yourself :/ (and even then, no guarantees how quickly I can review the PR)

from auto_impl.

dhardy avatar dhardy commented on July 19, 2024 1

FYI trait-objects are supported by impl-tools (see tests) for examples).

from auto_impl.

LukasKalbertodt avatar LukasKalbertodt commented on July 19, 2024

I think this would be a useful addition to the library. However, won't have time to implement this any time soon.

Also, there are some open questions, in particular how to specify those types in the #[auto_impl(...)] attribute. Maybe we should support #[auto_impl(Box<dyn>)] (trait object) and #[auto_impl(Box<impl>)] (the current behavior, static dispatc). And #[auto_impl(Box)] would just add both impl blocks? Just some quick ideas. I'd love to find a brief, easy to read and general syntax to specify impl blocks that auto-impl should generate. Ideas welcome!

from auto_impl.

dpc avatar dpc commented on July 19, 2024

I think Box<dyn> looks OK, and the previous ones can stay as they were.

Alternatively:

  • #[auto_impl(Box)] does both #[ auto_impl_dyn(Box)] and #[auto_impl_stat(Box)] do one or the other

from auto_impl.

daniel5151 avatar daniel5151 commented on July 19, 2024

I'd also love to see this added. It would let me remove this gnarly macro from my project 😄

Aside from Box<dyn T>, there's also &dyn T and &mut dyn T as well.

I would recommend keeping the two impls separate, as not all Traits can be used as Trait Objects (see Object Safety).

from auto_impl.

daniel5151 avatar daniel5151 commented on July 19, 2024

Seeing as #72 was just resolved, this is the only other issue that's blocking me from using auto_impl in my project.

Any updates on if/when this could get implemented?

from auto_impl.

KodrAus avatar KodrAus commented on July 19, 2024

This is probably something best left to impl-tools to handle. This library is quite tightly focused on a single simple use-case, so I've opened #79 to point users to it if they need something more sophisticated.

from auto_impl.

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.