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
println!("first");for i in(0..640).step_by(128){println!("{}", i)}println!("second");for i in(0..640).step_by(128).skip(1){println!("{}", i)}println!("third");for i in(0..640).step_by(128).map(|i| i).skip(1){println!("{}", i)}
It prints:
first
0
128
256
384
512
second
128
129
257
385
513
third
128
256
384
512
I expect second iterator to produce the same result as for the third one.
From a cursory look, it seems to me that the problem is that nth and next are out of sync. StepBy specifically allows two different kind of semantics for the underlying iterator, either next(), nth(step-1), nth(step-1), … or advance_n_and_return_first. If both next and nth follow the same one, the bug shouldn't occur.
In other words, if next is specialized and nth overrides the default, then nth needs to be specialized as well.
Activity
jethrogb commentedon Nov 15, 2018
Regression from 1.28.0 to 1.29.0. Introduced in #51601
m1el commentedon Nov 15, 2018
The problem is interaction between
StepBy::nthandStepBySpecIterator::spec_next.spec_nextignores the inner working of StepBy.Test-case reduced to using
StepBywithoutSkip.Emerentius commentedon Nov 19, 2018
From a cursory look, it seems to me that the problem is that
nthandnextare out of sync. StepBy specifically allows two different kind of semantics for the underlying iterator, eithernext(), nth(step-1), nth(step-1), …oradvance_n_and_return_first. If bothnextandnthfollow the same one, the bug shouldn't occur.In other words, if
nextis specialized andnthoverrides the default, thennthneeds to be specialized as well.Auto merge of #56049 - newpavlov:revert_51601, r=sfackler