Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReplace deprecated Range::step_by() with Iterator::step_by() #17359
Comments
|
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the If you intend to work on this issue, then add |
|
@highfive: assign me |
|
Hey @jklepatch! Thanks for your interest in working on this issue. It's now assigned to you! |
|
I did a first try but didnt succeed. I posted a related question on the Rust issue tracker: |
|
You may need to use something like |
Successful Attempt:
I followed this example: https://github.com/servo/servo/blob/master/components/net_traits/image/base.rs#LC53 Although it compiles, It's still not correct because iterating over a range defined with the higher bound first and lower bound after does not work as expected (first branch of the I have created this rust playground to illustrate my point: FYI, below are all my unsuccesful attempts Unsuccessful Attempt
|
|
I agree, I don't think that step_by adds anything useful here. Calling rev() will result in more readable code. |
|
I tried the below solution, but it didnt work because the 2 branches of the
I tried to call I was thinking of 2 other solutions:
Any opinions? |
|
Good points! I think the enum would be the best way forward; if you implement the Iterator trait for it by invoking the next() method on each contained iterator type, I think it should work fine. |
|
Another option would be a "conditional reverse" adapter, as described here: rust-lang/rust#27741 (comment) |
|
Fixed in #17605. |
https://doc.servo.org/core/ops/struct.Range.html#method.step_by
https://doc.servo.org/core/iter/trait.Iterator.html#method.step_by
This will require replacing the existing
#[feature(step_by)]with#[feature(iterator_step_by)]at the very least.