1、常规的for
代码:
let mut list :[i32;5] = [1,2,3,4,5];
for em in list.iter(){
println!("输出: {}",em)
}
2、range
for i in (1..4).rev(){ // (1..4)就是Range用法,那么rev()就是反转咯
println!("the values is {}",i)
}
2024-03-16 12:54:46
代码:
let mut list :[i32;5] = [1,2,3,4,5];
for em in list.iter(){
println!("输出: {}",em)
}
for i in (1..4).rev(){ // (1..4)就是Range用法,那么rev()就是反转咯
println!("the values is {}",i)
}