mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
27 lines
432 B
Rust
27 lines
432 B
Rust
fn calc_idx(i: usize) -> usize {
|
|
(i + i + 20) % 4
|
|
}
|
|
|
|
fn main() {
|
|
let ns = [2, 3, 5, 7];
|
|
|
|
for i in 3..10 {
|
|
println!("{}", ns[i]);
|
|
}
|
|
|
|
for i in 3..10 {
|
|
println!("{}", ns[i % 4]);
|
|
}
|
|
|
|
for i in 3..10 {
|
|
println!("{}", ns[i % ns.len()]);
|
|
}
|
|
|
|
for i in 3..10 {
|
|
println!("{}", ns[calc_idx(i)]);
|
|
}
|
|
|
|
for i in 3..10 {
|
|
println!("{}", ns[calc_idx(i) % 4]);
|
|
}
|
|
}
|