-
Notifications
You must be signed in to change notification settings - Fork 633
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
impl<T: DerefMut<Target=U>, U: ?Sized + Future> Future for T? #479
Comments
My concrete use case here is an |
Thanks for the report! I haven't played around with this much, but historically having blanket impls like this tends to cause problems related to coherence in many other external crates. I'm not 100% sure though if this would cause problems? I agree it'd be great to have a "smart pointers of futures are they themselves futures" be automatic though! |
I didn't really understand your problem, can't you What you propose is to replace the impl for
Point 1 means we may regret adding this instead of something else, point 2 means it's harder to add it later. The only contenders I can think of are |
I can't, though the
Yes.
There isn't one yet, afaict, and this seems like a pretty good candidate! |
I haven't done any significant amount of Rust API design but this seems pretty sane. The Deref traits are already somewhat magical since the compiler will use them for coercion, so implementers should already be cautious here. I have seen people abusing Deref for inheritance but that's already pretty crazy. |
Ah, I thought you had defined |
Indeed, that does fail. AIUI that rule exists in general because if the ancestor crate's type were to grow trait implementations that satisfied the bounds in the future (no pun intended) then we would get a coherence violation. In this particular case though, it's hard to see how Perhaps the fundamental (pun actually intended this time) problem here is that |
Interesting point about |
Well if |
Unfortunately I believe this can't be done today:
|
er ...
As a result, I'm going to close this. |
There's already an
impl<'a, F: ?Sized + Future> Future for &'a mut F
. This seems like a logical extension.The text was updated successfully, but these errors were encountered: