rust - What is the idiomatic way to write a for loop without using the iterator value? -


assuming want finite loop using range:

let mut x: i32 = 0; in 1..10 {     x += 1; } 

the compiler spit out warning:

warning: unused variable: `i`, #[warn(unused_variables)] on default in 1..10 {     ^ 

is there more idiomatic way write won't make compiler complain?

you can write _ pattern, meaning “discard value”:

let mut x: i32 = 0; _ in 1..10 {     x += 1; } 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -