You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Step::steps_between does not distinguish overflow and unimplemented (unstable) #48117
Require that the method is implemented accurately (easy for fundamental integers; harder if Step is expected to support graph walks, but maybe not harder than PartialOrd)
Change the type to something else, maybe Option<Option<usize>> or be more hint-like with (usize, Option<usize>)
@CAD97 Yes, I think there's still essentially the same problem -- the Invariants section still has None for both unreachable (steps_between(1, 0)) and overflow (steps_between(0_u128, 1<< 127)).
So if this is used for size_hint, then getting None back from steps_between means you're stuck returning (0, None), when you'd rather be able to return either (0, Some(0)) or (usize::MAX, None).
Looks like this was updated, but I realized it's unclear, at least to me, what to do if it's actually unreachable -- should that be marked distinctly? Step only requires PartialOrd, not Ord, so a and b might both have successors and predecessors but neither is reachable from the other.
Or if (0, None) is always a legal response, shouldn't it be a provided implementation like Iterator::step_by?
Activity
CAD97 commentedon May 15, 2020
The links appear to have lost their original position.
Does the original concern still stand? (Does it stand with #69659?)
scottmcm commentedon Aug 4, 2020
@CAD97 Yes, I think there's still essentially the same problem -- the Invariants section still has
Nonefor both unreachable (steps_between(1, 0)) and overflow (steps_between(0_u128, 1<< 127)).So if this is used for
size_hint, then gettingNoneback fromsteps_betweenmeans you're stuck returning(0, None), when you'd rather be able to return either(0, Some(0))or(usize::MAX, None).scottmcm commentedon Jul 12, 2026
Looks like this was updated, but I realized it's unclear, at least to me, what to do if it's actually unreachable -- should that be marked distinctly? Step only requires PartialOrd, not Ord, so
aandbmight both have successors and predecessors but neither is reachable from the other.Or if
(0, None)is always a legal response, shouldn't it be a provided implementation likeIterator::step_by?