Is it possible to declare the type of the variable in Rust for loops?

You can use an integer suffix on one of the literals you’ve used in the range. Type inference will do the rest:

for i in 1i64..101 {
    println!("{}", i);
}

Leave a Comment