Skip to content

range(a, b) does not work when a > b #9555

Closed
@jesseray

Description

@jesseray

This code works:

fn main() {
    for i in range(0, 256) {
        println(i.to_str());
    }
}

but this code doesn't:

fn main() {
    for i in range(255, -1) {
        println(i.to_str());
    }
}

The compiler shows no warnings or errors and the executable produces no output:

[jesse@localhost ~]$ rustc nums.rs
[jesse@localhost ~]$ ./nums
[jesse@localhost ~]$ 

It seems to me that range(a, b) should work for both cases, a < b and a > b.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions