Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDefault type parameter fallback revisited #2321
Conversation
leodasvacas
referenced this pull request
Feb 3, 2018
Closed
Change impls of `PartialEq` and friends in libstd to be more generic #2245
kennytm
reviewed
Feb 3, 2018
|
|
||
| Defaults may be set for type parameters in in traits, impls, struct and enum definitions and also methods and fns. They may not be set in `type` aliases. They also may not be set in methods and associated fns of trait impls, such defaults can only be set in the trait declaration. As per RFC 213, parameters with defaults must be trailing and may not be forward declared. | ||
|
|
||
| The behaviour of omited parameters in partially supplied parameter lists is as per RFC 213, they are inferred as if filled in with `_`. This is relevant to this [postoned RFC](https://github.com/rust-lang/rfcs/pull/1196) that suggests extending that behaviour to non-defaulted parameters. |
This comment has been minimized.
This comment has been minimized.
|
|
||
| ```rust | ||
| fn foo<T=String>(x: Option<T>); | ||
| fn bar<U>(y: Option<T>); // What if we had `fn bar<U=usize>`? |
This comment has been minimized.
This comment has been minimized.
leodasvacas
changed the title
Default type parameter fallback revisited.
Default type parameter fallback revisited
Feb 3, 2018
Centril
added
the
T-lang
label
Feb 3, 2018
This comment has been minimized.
This comment has been minimized.
|
I've only done a quick initial reading, but it seems compatible with RFC #2176 (partial turbofish). |
This comment has been minimized.
This comment has been minimized.
|
@Centril Yes this is intended to be compatible with that RFC, see this paragaph:
|
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
from
97e2780
to
8320e56
Feb 3, 2018
This comment has been minimized.
This comment has been minimized.
|
@leodasvacas Wonderful! Then they don't need to block each other. Might I suggest adding a reference to #2176 in the relevant paragraph? For the roll-out plan, I suggest implementing #2176 first since it's a rather simple change and is a step on the way to this RFC. |
leodasvacas
added some commits
Feb 3, 2018
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb |
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
from
5c164bb
to
6226568
Feb 9, 2018
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
from
6226568
to
587b9bf
Feb 9, 2018
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Noticed your confused emoji reaction, would you like to expand on that? |
This comment has been minimized.
This comment has been minimized.
|
The reference explanation is still somewhat guide-y and missing some precision. I'm having a hard time understanding how the concerns from before about multiple defaults are mitigated, for example. +1 on the basic idea/goals though. |
This comment has been minimized.
This comment has been minimized.
|
@leodasvacas |
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
from
1069c50
to
295be8b
Feb 14, 2018
This comment has been minimized.
This comment has been minimized.
|
@Ericson2314 @petrochenkov The algorithm for applying fallback remains the one specified in RFC 213 modulo some considerations that I've added to this RFC. This RFC accepts that the algorithm fails on conflicting fallbacks and tries to mitigate that by documenting the practical implications to API evolution and proposing default elision, but there is no mitigation in the algorithm itself. |
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
5 times, most recently
from
f40c1b7
to
a18e7c1
Mar 15, 2018
leodasvacas
force-pushed the
leodasvacas:default-parameter-fallback-take-two
branch
from
a18e7c1
to
c7171f4
Mar 15, 2018
This comment has been minimized.
This comment has been minimized.
|
Note that @Centril, @leodasvacas and some others are now taking up discussion related to default type parameters on functions, turbofish, and more -- hopefully resulting in a new RFC. As such, I'm going to close this one for the time being. |
leodasvacas commentedFeb 3, 2018
•
edited
Thanks @nikomatsakis for early feedback! Tracking issue of the previous RFC rust-lang/rust#27336.
Rendered