Closed
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
Tracking issue for the start, end and new methods of RangeInclusive.
(Originally the tracking issue for rust-lang/rfcs#1980 the start and end fields, but we decided to make the representation private in #49022 (comment))
Steps:
- Implementation Introduce RangeInclusive::{new, start, end} methods and make the fields private. #49724
- Stabilization PR Stabilise inclusive_range_methods #50758
Unresolved questions:
-
Should we want to expose the fields as public (stabilize as is), or simply provide getter methods and don't show the implementation detail (redesign from scratch)?
This issue is separated from #28237 since there were vocal oppositions from the community (see #47813) due to performance loss if we commit to the two-field design.
If you want start and end, please use these for now:
x.start()↦x.next().unwrap()x.end()↦x.next_back().unwrap()
Reacted by Lily
Metadata
Metadata
Assignees
Labels
B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-api[DEPRECATED; DO NOT USE][DEPRECATED; DO NOT USE]final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Activity
scottmcm commentedon Mar 15, 2018
Two important points here:
fold& friends), just like other types (such asChain) that can be faster if you use internal iteration instead of aforloop.RangeInclusivecompared to aRange, since the loop body fundamentally must do something different in the last iteration in the interesting caseAs I've said before, the optimal choice here would be to only have the range types be
IntoIterator(notIterator), but that change requires a time machine, so I think being likeRangeis best.SimonSapin commentedon Mar 30, 2018
The libs team discussed this and the consensus was to make all fields private, provide accessor methods, and add a boolean field to implement iteration in a way that hopefully optimizes better.
If someone has a use case for moving bounds out, they should request something like
pub fn into_inner(self) -> (Idx, Idx)to be added. The methods of theRangeBoundstrait (formerlyRangeArgument) are to be renamedstart_boundandend_boundto avoid name collision.@rfcbot fcp merge
rfcbot commentedon Mar 30, 2018
Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams:
No concerns currently listed.
Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
scottmcm commentedon Mar 31, 2018
What exact this this FCPing? It feels odd that the last two times the class was modified it was via RFC, but this time it's just a "hopefully", not even a PR.
SimonSapin commentedon Mar 31, 2018
This is not making again deep changes to the data structure or syntax, only picking one of two already-proposed alternatives. And the more conservative one, since methods can keep working even if the internal structure changes.
kennytm commentedon Apr 5, 2018
Simply making the fields private will break lowering of
..=😒Therefore
x..=ywill need to lower to something likeRangeInclusive::new(x, y). Should the constructor be exposed or#[doc(hidden)]? Or we keep the fields public and perma-unstable them?SimonSapin commentedon Apr 5, 2018
I’d be fine with
#[doc(hidden)]perma-unstable public fields, but we might want an constructor function anyway if the fields are "effectively private". Is lowering to a call difficult or inconvenient?kennytm commentedon Apr 5, 2018
It needs a special case in https://github.com/rust-lang/rust/blob/56714acc5eb0687ed9a7566fdebe5528657fc5b/src/librustc/hir/lowering.rs#L3082 for the
ExprKind::Range(Some(..), Some(..), Closed)case. Not very difficult, just different.9 remaining items
rfcbot commentedon Apr 10, 2018
🔔 This is now entering its final comment period, as per the review above. 🔔
rfcbot commentedon Apr 20, 2018
The final comment period is now complete.
Auto merge of #49724 - kennytm:range-inc-start-end-methods, r=Kimundi
SimonSapin commentedon May 9, 2018
Adding
into_innersounds good to me. Wanna send a PR?Rollup merge of rust-lang#50574 - s3bk:range_inclusive_into_inner, r=…
Rollup merge of rust-lang#50574 - s3bk:range_inclusive_into_inner, r=…
Auto merge of #50758 - varkor:stabilise-inclusive_range_methods, r=Si…