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 upTracking issue for `start`, `end` and `new` methods of RangeInclusive #49022
Comments
kennytm
added
T-libs
B-unstable
C-tracking-issue
labels
Mar 14, 2018
kennytm
self-assigned this
Mar 14, 2018
This comment has been minimized.
This comment has been minimized.
|
Two important points here:
As I've said before, the optimal choice here would be to only have the range types be |
bors
added a commit
that referenced
this issue
Mar 15, 2018
bors
added a commit
that referenced
this issue
Mar 15, 2018
nikomatsakis
referenced this issue
Mar 15, 2018
Closed
Tracking issue for `..=` inclusive ranges (RFC #1192) -- originally `...` #28237
This comment has been minimized.
This comment has been minimized.
|
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. impl<Idx> RangeInclusive<Idx> {
pub fn start(&self) -> &Idx {…}
pub fn end(&self) -> &Idx {…}
}If someone has a use case for moving bounds out, they should request something like @rfcbot fcp merge |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
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. |
rfcbot
added
the
proposed-final-comment-period
label
Mar 30, 2018
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Simply making the fields private will break lowering of
Therefore |
This comment has been minimized.
This comment has been minimized.
|
I’d be fine with |
This comment has been minimized.
This comment has been minimized.
|
It needs a special case in https://github.com/rust-lang/rust/blob/56714acc5eb0687ed9a7566fdebe5528657fc5b/src/librustc/hir/lowering.rs#L3082 for the |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure that a doc(hidden) perma-unstable function is better than doc(hidden) perma-unstable fields. |
This comment has been minimized.
This comment has been minimized.
|
Why not stabilize that function? Other range types can be created as struct literals in addition to the dedicated syntax. |
This comment has been minimized.
This comment has been minimized.
|
I agree with @SimonSapin, it seems reasonable to have a stable constructor for the type. |
kennytm
changed the title
Tracking issue for RFC 1980, `start` and `end` fields of RangeInclusive
Tracking issue for `start`, `end` and `new` methods of RangeInclusive
Apr 5, 2018
kennytm
referenced this issue
Apr 6, 2018
Merged
Introduce RangeInclusive::{new, start, end} methods and make the fields private. #49724
This comment has been minimized.
This comment has been minimized.
|
While i think those methods are fine, i believe (at least) the constructor should be const fn... |
This comment has been minimized.
This comment has been minimized.
|
What advantage does the |
This comment has been minimized.
This comment has been minimized.
|
@scottmcm There is no advantage using the method.
The question is only whether we want to eventually stabilize |
This comment has been minimized.
This comment has been minimized.
|
@kennytm Fair enough, makes sense if the goal is private fields. A thought, since I don't know what was discussed: could the struct be |
This comment has been minimized.
This comment has been minimized.
|
@scottmcm This will allow mutating |
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Apr 10, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 10, 2018
|
|
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 20, 2018
|
The final comment period is now complete. |
bors
added a commit
that referenced
this issue
May 1, 2018
This comment has been minimized.
This comment has been minimized.
ghost
commented
May 9, 2018
•
|
This makes it very difficult/impossible when
I hereby request |
This comment has been minimized.
This comment has been minimized.
|
Adding |
ghost
referenced this issue
May 9, 2018
Merged
add fn `into_inner(self) -> (Idx, Idx)` to RangeInclusive (#49022) #50574
This comment has been minimized.
This comment has been minimized.
ghost
commented
May 9, 2018
|
@SimonSapin done! #50574 |
kennytm commentedMar 14, 2018
•
edited by varkor
Tracking issue for the
start,endandnewmethods ofRangeInclusive.(Originally the tracking issue for rust-lang/rfcs#1980 the
startandendfields, but we decided to make the representation private in #49022 (comment))Steps:
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
startandend, please use these for now:x.start()↦x.next().unwrap()x.end()↦x.next_back().unwrap()