-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box<TraitObject> should impl TraitObject #20617
Comments
This is indeed possible for
You can't implement that trait for a |
It is not clear to me if we want this for |
Yeah, a deriving mode might work. |
A "derive all traits" and a "derive all traits that don't take self by value" and a "derive all traits that only take self by immutable reference" would be nice. This way you don't have to implement the trait for |
On a side note, taken to its extreme it feels like the current system of object safety would eventually lead to the ideal of one method per object-safe trait, and allow arbitrary combinations of them (so you could freely combine whatever combination of object-safe methods you need for your usecase). But at that point object-safe traits are basically just unboxed closures, and casting to a trait object (e.g. for traits |
closes rust-lang#20953 closes rust-lang#21361 --- In the future, we will likely derive these `impl`s via syntax extensions or using compiler magic (see rust-lang#20617). For the time being we can use these manual `impl`s. r? @aturon cc @BurntSushi @Kroisse
Triage: we did this, didn't we? |
On Mon, Jan 04, 2016 at 01:44:05PM -0800, Steve Klabnik wrote:
Not quite. We made it so that the type
|
I guess if the issue is about a new deriving mode, as we discussed earlier, I could get behind it. But I think the idea of auto-implementing traits feels...perilous and complex. We've largely failed at attempts to achieve this sort of magic. |
The following is another example of a trait that, despite being object-safe, cannot be implemented automatically for trait Foo {
fn foo(&self, other: &Self) where Self: Sized;
} |
I get the feeling from reading this that there's not really a clear path forward, and we're not even sure we want this. Either way, it feels like it's something that would need to go through an RFC, so perhaps this should be closed (and if interest still exists, refiled as an RFC issue). |
Sure. Looks like this wants to be an RFC. |
Also
&TraitObject
,&mut TraitObject
, etc. (I think raw pointers can also reference trait objects). I believe this should be possible now that object safe traits always implement themselves.cc @nikomatsakis
The text was updated successfully, but these errors were encountered: