我对i下面的变量做错了什么?为什么编译器说我不能Vec用 a索引 a ,u32我该如何解决?
fn main() {
let a: Vec<u32> = vec![1, 2, 3, 4];
let number: u32 = 4;
let mut count = 0;
for i in 0..number {
if a[i] % 2 != 0 {
count += 1;
} else {
continue;
}
}
println!("{}", count);
}
Run Code Online (Sandbox Code Playgroud)
错误:
fn main() {
let a: Vec<u32> = vec![1, 2, 3, 4];
let number: u32 = 4;
let mut count = 0;
for i in …Run Code Online (Sandbox Code Playgroud)