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 `step_by` stabilization #27741
Comments
aturon
added
T-libs
B-unstable
I-nominated
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
Nominating for P-High. |
Ms2ger
referenced this issue
Aug 16, 2015
Open
Tracking: Unstable Rust feature gates used by Servo #5286
aturon
self-assigned this
Aug 19, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: P-high |
rust-highfive
added
P-high
and removed
I-nominated
labels
Aug 19, 2015
This comment has been minimized.
This comment has been minimized.
|
cc #23588 |
This comment has been minimized.
This comment has been minimized.
|
We should probably start moving on this in the next cycle or drop the P-high. |
alexcrichton
added
the
I-nominated
label
Sep 17, 2015
brson
unassigned
aturon
Sep 23, 2015
aturon
added
the
E-mentor
label
Sep 23, 2015
This comment has been minimized.
This comment has been minimized.
|
Would definitely like some help getting this over the finish line. I'm happy to mentor! |
This comment has been minimized.
This comment has been minimized.
|
The library subteam decided to not move this to FCP this cycle. The API is pretty likely to need revision in one form or another and that should be taken care of before a FCP happens. I believe discussion is still going on in the internals post though! Also moving to P-medium |
alexcrichton
added
P-medium
and removed
I-nominated
P-high
labels
Sep 24, 2015
This comment has been minimized.
This comment has been minimized.
|
It seems odd to me that the |
This comment has been minimized.
This comment has been minimized.
|
Where do we stand on this at the moment? This is a feature I'd very much like to use in stable, and am willing to provide help to get this finalized (with some mentoring). |
This comment has been minimized.
This comment has been minimized.
|
Based on the documentation, I would expect |
This comment has been minimized.
This comment has been minimized.
|
Why do you expect that? Overflowing the range of an integer type is an error (it panics in debug mode), it’s not the expected end of a |
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin The example for for i in (0u8..).step_by(2) {
println!("{}", i);
}I think that this example is misleading: its explanation says "This prints all even u8 values.", but instead it overflows on panic in debug and loops forever in release. |
This comment has been minimized.
This comment has been minimized.
|
Indeed, that example is wrong. How does this look? #31172 |
This comment has been minimized.
This comment has been minimized.
|
Ditto @dschatzberg's comment. Imagine something like stepping through a range of two |
This comment has been minimized.
This comment has been minimized.
|
A sequence of floats like 0.1, 0.2, ..., 0.5 is so common in numerical codes that Matlab has a built-in operator for it: But I understand your rigorous approach but it would be handy to have |
This comment has been minimized.
This comment has been minimized.
|
Also, I think we should consider inclusion of which, to my eyes, is more generic (applicable to all iterators) |
This comment has been minimized.
This comment has been minimized.
yigal100
commented
Mar 27, 2016
|
IMHO, step_by should be a general abstraction for all iterators as mentioned by @nodakai and the current implementation that uses addition must be at most a specialization for efficiency sake for integral types (now that Rust has specialization implemented). |
This comment has been minimized.
This comment has been minimized.
|
yigal100's approach seems sensible, in which case Another option would be to drop Neither of these options requires a The questions which I think need answering are: 1 What are the main use-cases?In my mind these are: a. producing a sequential list of array indices (i.e. non-negative integers), usually stepping by +1 but possibly also -1, 2, etc., and 2 What restrictions are there on syntax / implementation?As far as I am aware, the Is there a fundamental reason that 3 Flexibility, optimizability and intuitivenessWhich is clearer, Is there any point allowing negative steps? Maybe not for indices since One thing I like about the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Mar 17, 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 17, 2018
This comment has been minimized.
This comment has been minimized.
|
Is there an RFC or post or something that documents the behavior being proposed for stabilization? I find it extremely hard to extract from this issue what is exactly being proposed for stabilization, what is the rationale, alternatives that have been explored, etc. I am not suggesting that this needs an RFC, but at least a summary of the work done and why what we have now is better and suitable for stabilization that what we had before. As a maintainer of collections implement step_by I would find such information useful to update my collections accordingly. |
This comment has been minimized.
This comment has been minimized.
|
@gnzlbg Yeah, this issue has a lot of history and can be hard to read now. https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.step_by
|
This comment has been minimized.
This comment has been minimized.
|
@SimonSapin thanks for the summary, that is really helpful. |
This comment has been minimized.
This comment has been minimized.
|
I agree that step_by is good for iterators in general, but we risk a situation where we have to advise not using .step_by on ranges, which is going to be uphill ergonomically. I had hopes With the right tooling and right method name, a “increment type matching” stepping adaptor for ranges might still be easy to find for users. Problems with
|
This comment has been minimized.
This comment has been minimized.
leonardo-m
commented
Mar 18, 2018
•
|
Could two different named methods ("step" and step_by"?) solve this issue, having one for ranges that takes an usize, and one for intervals that takes the same type as the interval? |
This comment has been minimized.
This comment has been minimized.
|
Can't we have the
Or something similar is this doesn't work out or if it's not desirable to add a new associated type to the |
This comment has been minimized.
This comment has been minimized.
|
@ivandardi If we did that |
This comment has been minimized.
This comment has been minimized.
|
@bluss How about renaming |
This comment has been minimized.
This comment has been minimized.
|
I’m ok with |
This comment has been minimized.
This comment has been minimized.
|
Semantics and naming choices like |
This comment has been minimized.
This comment has been minimized.
|
Then how about |
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 18, 2018
|
|
rfcbot
added
final-comment-period
and removed
proposed-final-comment-period
labels
Apr 18, 2018
This comment has been minimized.
This comment has been minimized.
rfcbot
commented
Apr 28, 2018
|
The final comment period is now complete. |
This comment has been minimized.
This comment has been minimized.
|
I looked at overriding mov r8d, eax
lea r9d, [rcx - 1]
lea eax, [rcx - 2]
xor eax, r9d
add eax, r8d
mov r9d, ecx
add r9d, 6
setb r8b
cmp r9d, edx
jae .LBB1_6
add ecx, 7
test r8b, r8b
je .LBB1_4which doesn't simplify further because of the slightly-awkward semantics of I think this'd be perfectly efficient in terms of a "return next and also step forward" method, since the Range iterator for that would just return |
Centril
added
disposition-merge
finished-final-comment-period
and removed
final-comment-period
labels
May 24, 2018
tmccombs
added a commit
to tmccombs/rust
that referenced
this issue
Jun 3, 2018
zslayton
referenced this issue
Jun 5, 2018
Closed
Noob question: why nightly ? is it a permanent choice ? #36
bors
added a commit
that referenced
this issue
Jun 10, 2018
bors
closed this
in
#51320
Jun 10, 2018
Emerentius
referenced this issue
Jun 14, 2018
Open
Ironing out StepBy<Range>'s performance issues #51557
This comment has been minimized.
This comment has been minimized.
|
Could we amend a note to While specializations of |
aturon commentedAug 12, 2015
•
edited by SimonSapin
Update (@SimonSapin): this is now the tracking issue for an iterator adaptor based on
Iterator::nth:The
Steptrait used for making ranges iterators is now tracked at #42168.Original issue:
The
step_bymethod makes it possible to step through ranges with arbitrary-sized steps. There are several issues that need to be addressed before we can stabilize it:Steptrait, which is currently a bit of a messZero/One, tracked here