Comments (8)
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.
@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.
FYI trait-objects are supported by impl-tools (see tests) for examples).
from auto_impl.
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.
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.
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.
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.
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)
- Emit warning on empty proxy type list HOT 3
- Make `Fn*` types work with some generic methods HOT 1
- Relicense as MIT/Apache-2 HOT 4
- Newtype support HOT 9
- Add `!` (never) as proxy type HOT 3
- auto_impl for trait objects? HOT 3
- Compiler error running tests
- Make impls apply for trait objects HOT 9
- Add proper compile-fail tests HOT 2
- Investigate using `syn-mid` HOT 3
- Proposal: throw away diag.rs module and use proc-macro-error crate HOT 3
- Unable to use auto_impl with async-trait HOT 17
- Use `Span::mixed_site` HOT 3
- `no_std` support HOT 2
- Support mutable function arguments HOT 1
- const generics support HOT 1
- Errors when using an associated type defined in a supertrait HOT 6
- Doesn't work with generic associated types HOT 1
- request for crates.io minor release with syn 2 upgrade HOT 4
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 auto_impl.