fn count_occur(v: &Vec<i32>, val: i32) -> usize {
0
}
fn main() -> () {
let v1 = vec![1, 2, 3, 4, 5, 6];
for &item in &v1 {
let v2 = count_occur(&v1, item);
println!("{}", v2);
}
}
item
是不可更改的借用参考。为什么编译器接受该代码?毕竟,count_occur
接受不借用对i32
的引用吗?