Skip to content

step_by + skip produce incorrect results #55985

Closed
@newpavlov

Description

@newpavlov

The following snippet demonstrates the problem:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions