-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Remove deprecated Range::step_by
(use Iterator::step_by
instead)
#42110
Conversation
Follow-up to rust-lang#41439 (comment) While doing so, remove the now-unused `step`, `steps_between`, and `is_negative` methods from `Step`. Mostly simple, but needed two interesting changes: * Override `Iterator::size_hint` for `iter::StepBy` (so hints aren't lost) * Override `Iterator::size_hint` for `ops::RangeFrom` (so `(0..).size_hint()` returns what `(0..).step_by(1).size_hint()` used to) (It turns out that `(0..).step_by(d)` is used in a bunch of tests, from `cycle` to `vec_deque`.) Incidentally fixes rust-lang#41477
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -199,7 +199,6 @@ | |||
- [sort_internals](library-features/sort-internals.md) | |||
- [sort_unstable](library-features/sort-unstable.md) | |||
- [splice](library-features/splice.md) | |||
- [step_by](library-features/step-by.md) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... The iterator_step_by
entry is missing from this list. Do you mind adding it, please? 😃
The current |
Updated with @ivandardi's suggestions. Crater is a good point. If it would help, I could split this into sequential PRs:
|
Thanks for the PR @scottmcm! Just to make sure I understand the current state of affairs:
If that's true, then I've got a few questions:
|
@alexcrichton Yup, that's the state of things.
I guess a better statement is that this is a removal of a fairly old feature, so it might be worth thinking about the impact even though it's only to nightly. But we probably don't need the certainty of a crater run, a GitHub search is likely sufficient. Is there a general preference between a breaking change going under a new feature (so the error is up-front and there's something to search) or re-using the existing feature (so basic but common uses -- here step_by a positive literal -- just continue to work)?
It's still used for impl<A: Step> Iterator for ops::Range<A>
impl<A: Step> Iterator for ops::RangeFrom<A>
impl<A: Step> Iterator for ops::RangeInclusive<A> (and all the more-specific iterators as well) I think the best thing to do with |
Ok cool, thanks for the clarifications! We historically have had a process around removing deprecated features from the standard library: (a) add a replacement (b) deprecate an api (c) wait a cycle and (d) delete the api. Nowadays though the amount of widely-used unstable apis in libstd seems to have drastically diminished so such a process may not be so required any more. In that sense a breaking change could be ok here if there's not a whole lot of users, but if there's a lot of users we may wish for a cycle of deprecation before removal. Does that make sense? |
That makes sense. Thanks for the advice; I just got too excited at deleting stuff 🙂 I'll close this and open some new, smaller PRs. |
…excrichton Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of rust-lang#42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…excrichton Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of rust-lang#42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…excrichton Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of rust-lang#42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…excrichton Give step_trait a distinct tracking issue from step_by iterator_step_by has decoupled their futures, so the tracking issue should split. Old issue: rust-lang#27741 New issue: rust-lang#42168 r? @alexcrichton (another follow-up to closed PR rust-lang#42110 (comment))
…ed-tail, r=eddyb extend `struct_tail` to operate over closures Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong. Fixes rust-lang#42110 r? @eddyb
…excrichton Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of rust-lang#42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…ed-tail, r=eddyb extend `struct_tail` to operate over tuples Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong. Fixes rust-lang#42110 r? @eddyb
…excrichton Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of rust-lang#42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…ed-tail, r=eddyb extend `struct_tail` to operate over tuples Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong. Fixes rust-lang#42110 r? @eddyb
…ed-tail, r=eddyb extend `struct_tail` to operate over tuples Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong. Fixes rust-lang#42110 r? @eddyb
…ed-tail, r=eddyb extend `struct_tail` to operate over tuples Not 100% sure why this got exposed when it wasn't before, but this struct definitely seems wrong. Fixes rust-lang#42110 r? @eddyb
Override size_hint and propagate ExactSizeIterator for iter::StepBy Generally useful, but also a prerequisite for moving a bunch of unit tests off `Range*::step_by`. A small non-breaking subset of #42110 (which I closed). Includes two small documentation changes @ivandardi requested on that PR. r? @alexcrichton
…alexcrichton Deprecate range-specific `step_by` Deprecation attributes and test updates only. Was replaced by an any-iterator version in rust-lang#41439 Last follow-up (this release) to rust-lang#42110 (comment) r? @alexcrichton
…alexcrichton Deprecate range-specific `step_by` Deprecation attributes and test updates only. Was replaced by an any-iterator version in rust-lang#41439 Last follow-up (this release) to rust-lang#42110 (comment) r? @alexcrichton
…alexcrichton Deprecate range-specific `step_by` Deprecation attributes and test updates only. Was replaced by an any-iterator version in rust-lang#41439 Last follow-up (this release) to rust-lang#42110 (comment) r? @alexcrichton
…alexcrichton Deprecate range-specific `step_by` Deprecation attributes and test updates only. Was replaced by an any-iterator version in rust-lang#41439 Last follow-up (this release) to rust-lang#42110 (comment) r? @alexcrichton
Follow-up to #41439 (comment)
While doing so, remove the now-unused
step
,steps_between
, andis_negative
methods fromStep
.Mostly simple, but needed two interesting changes:
Iterator::size_hint
foriter::StepBy
(so hints aren't lost)Iterator::size_hint
forops::RangeFrom
(so(0..).size_hint()
returns what(0..).step_by(1).size_hint()
used to)(It turns out that
(0..).step_by(d)
is used in a bunch of tests, fromcycle
tovec_deque
.)Incidentally fixes #41477