-
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
Add feature-gated Never-based types #101
Conversation
|
||
/// A future which is never resolved. | ||
/// | ||
/// This future can be created with the `empty` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/empty/never/
Also, I was going to give |
Nah I unfortunately don't know much about default type paramters :( |
@cramertj the discussion on this issue looks relevant: rust-lang/rust#27336 |
@kamalmarhubi Thanks! So, after all that, it works just fine like this as long as I include the |
Unfortunately the I've heard musings that it's pretty unlikely for the struct Empty<T=!, E=!> { ... } seems pretty neat! I actually really like how that easily works with invocations today and would just make some other invocations more ergonomic. I wonder, could this PR basically do that? If you enable the We could then perhaps pursue in parallel combinators on |
@alexcrichton Yeah, I'd love to have this implemented as just default type parameters on existing structs. I've just been floundering trying to figure out how to do that since default type parameters don't work on functions. Do you have an idea for how to do it without depending on the |
We don't get the fallback benefits from default type parameter fallback, but I think we should be able to do it nonetheless? Ah yeah and it looks like functions won't work, just structs. |
@alexcrichton Yes, but it seems like the primary use of |
I'm afraid I can't quite follow the discussion in these comments -- but I would say that the future of default type parameters is definitely in doubt, and getting more data on how people would like to use them might help to resolve some of that uncertainty. |
@cramertj so to clarify, if you add default type parameters to the |
@alexcrichton Correct. It only helps with the case where you're declaring |
Ah oh well :( In that case, are there still vectors we should modify in this PR? Or should we close? |
We could go ahead and make the default type parameter addition with the understanding that it might never get stabilized. Otherwise, I'm inclined to close. I'm kind of bummed out about it though, since there are several nice things about this approach. It's just not worth having to type |
Ok, I'd be game for that modification! |
Okay! I'll do that tonight and we can finally put this silly thing to rest. Thanks for your patience. |
Alas, there are some missing trait impls for |
It sounds like |
Thanks! What did you think though about the |
Yes, that should be backwards compatible. However, I'd still argue that It'd also require switching out the definitions based on whether or not the feature flag is set (i.e. not including the old struct and fn definitions if |
Yeah I think that'd be my preferred course of action here. I think it's additive too as well, right? It's just adding defaults for a few type parameters? |
It's additive in terms of behavior, but the actual implementation will require omitting some blocks of code based on the feature, i.e. |
Ah yeah having duplicate struct definitions is fine |
After all that, it's still not possible to make this a backwards compatible change. Defaulted type parameters must be come after type parameters with no defaults. This means that I'm going to close this PR, as it seems to me that the additional ergonomics offered by this PR are not worth the additional headache caused by dealing with two unstable features and their own set of ergonomic problems. It might be worth revisiting this after |
Ok, thanks for the investigation regardless @cramertj! |
Thanks for your support @alexcrichton! I appreciate it. |
This is a resumption of #75. Fix #32.
@alexcrichton Is this what you had in mind for how the feature flag would look?