-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rename end
field of inclusive Range
APIs to last
#511
Comments
I don't think the compatibility issue mentioned under 'Disadvantages' above is really a big problem for 2 reasons:
|
There is no new |
Ah, yes, that does make quite a difference. Maybe in the future there could be a smoother solution for the compatibility problems inherent in |
In the libs-api call today, this was discussed, and people were generally inclined toward accepting it, on the basis that if we're going to do a migration here, we might as well fix everything that we can as part of that. We wanted to check first, though, @pitaj, for your thoughts and whether this sounds right to you overall. |
I'm not opposed. My only reservation is that adding a new |
Since @pitaj is OK with this then we consider this ACP accepted. |
Proposal
Problem statement
RangeToInclusive
contains anend
field that has the same name, but slightly different semantics to theend
field ofRangeTo
. This means that innocuous-looking changes like replacing..=n-1
with..n
can cause silent behaviour changes and off-by-one bugs. Such changes are suggested by theclippy::range_minus_one
andclippy::range_plus_one
lints. This issue continues to exist in the newcore::range::RangeToInclusive
API, and will now also affectcore::range::RangeInclusive
.Motivating examples or use cases
Solution sketch
Rename the
end
field tolast
in the unstablecore::range::RangeInclusive
andcore::range::RangeToInclusive
types. The legacycore::ops::RangeInclusive
andcore::ops::RangeToInclusive
types would not be changed, to preserve backwards compatibility.Disadvantages
RangeToInclusive
type would have to be introduced, rather than re-exporting the original type, causing additional compatibility issues that do not presently exist.RangeInclusive
would be less affected, as it is already a new type, and existing users already have to change.end()
to.end
.Alternatives
end()
method onRangeInclusive
that steers users towards the newlast
field. This unfortunately would not work forRangeToInclusive
, whereend
is already a field.RangeInclusive
to avoid some incompatibility, but that would create a peculiar inconsistency.Links and related work
rust-lang/rust-clippy#3307 (comment)
rust-lang/rust#125687 (comment)
What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: