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_trait` stabilization #42168
Comments
scottmcm
referenced this issue
May 23, 2017
Merged
Give step_trait a distinct tracking issue from step_by #42169
alexcrichton
added
B-unstable
T-libs
labels
May 23, 2017
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
May 23, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 24, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 24, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 26, 2017
Mark-Simulacrum
added a commit
to Mark-Simulacrum/rust
that referenced
this issue
May 26, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 26, 2017
frewsxcv
added a commit
to frewsxcv/rust
that referenced
this issue
May 26, 2017
scottmcm
referenced this issue
May 27, 2017
Closed
Tracking issue for `step_by` stabilization #27741
This comment has been minimized.
This comment has been minimized.
|
Some progress on this in #42534 |
SimonSapin
referenced this issue
Jul 5, 2017
Merged
Implement O(1)-time Iterator::nth for Range*, and slim the Step trait #43077
This comment has been minimized.
This comment has been minimized.
|
PR #43077 does items 1 |
This comment has been minimized.
This comment has been minimized.
|
I’ve removed the i128/u128 stuff from my PR because I suspect my mixed-signdeness mixed-width interger arithmetic was buggy. I also massaged the /// Supporting trait for allowing ranges of various different types to be iterators.
#[unstable(feature = "step_trait",
reason = "recently redesigned",
issue = "42168")]
pub trait Step: Clone + PartialOrd + Sized {
/// Returns the number of steps between two step objects. The count is
/// inclusive of `start` and exclusive of `end`.
///
/// Returns `None` if it is not possible to calculate `steps_between`
/// without overflow.
fn steps_between(start: &Self, end: &Self) -> Option<usize>;
/// “Go forward” (for integers, add) the given number of steps, returning None on overflow.
fn forward(&self, step_count: usize) -> Option<Self>;
/// “Go backward” (for integers, subtract) the given number of steps, returning None on overflow.
fn backward(&self, step_count: usize) -> Option<Self>;
/// Modify the given inclusive range so that it becomes empty,
/// for example by setting it to `1...0`.
fn make_inclusive_range_empty(range: &mut ops::RangeInclusive<Self>);
}How does it look? I’m a bit uncertain of the exact impls for integers, there is up to 6 cases to consider: {smaller, same width, larger} than usize/isize × {signed, unsigned}. |
bors
added a commit
that referenced
this issue
Jul 8, 2017
SimonSapin
referenced this issue
Jul 8, 2017
Closed
Redesign the std::iter::Step trait, tweak related iterator impls for ranges #43127
This comment has been minimized.
This comment has been minimized.
|
I’ve tweaked this design some more and opened #43127. I believe that PR fixes every issue I know of around the |
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
I’ve closed that PR since it needs more work that I’m not planning to do soon: #43127 (comment). Hopefully someone else can take over. |
scottmcm
referenced this issue
Feb 12, 2018
Open
Step::steps_between does not distinguish overflow and unimplemented (unstable) #48117
This comment has been minimized.
This comment has been minimized.
|
I just wanted to leave a note saying that if methods with the behavior of Having said that, it sounds like these methods are scheduled to be either removed or replaced with something more generally useful? Update: (maybe if I care about this, I should spend effort reviving PR #43127...) |
scottmcm commentedMay 23, 2017
•
edited
Split off from #27741 because the stabilization path for
step_byhas moved to being on iterators (#41439), and thus not using theSteptrait.step,steps_between, andis_negativeonce Range::step_by is deletedreplace_zeroandreplace_onewith something more useful (some options: rust-lang/rfcs#1980 (comment))steps_between_by_oneso thatRange<u128>can beTrustedLen(rather than it only working well with types that fit inusize)(and probably more)