What can I do to iterate over an array of integers in Rust?
fn main () {
let mut array: Vec<i64> = vec![2];
for k in range(3, 13195) {
for p in array.iter() {
if (k % p != 0) {array.push(p)};
}
}
}
Gives me the compiler error:
rustc "Task2_minimalcode.rs" (im Verzeichnis: C:\Users\XXX\Documents\Rust - Project Euler)
Task2_minimalcode.rs:7:14: 7:15 error: mismatched types: expected
_
, found&i64
(expected integral variable, found &-ptr) [E0308] Task2_minimalcode.rs:7 if (k % p != 0) {array.push(p)};
^ Task2_minimalcode.rs:7:34: 7:35 error: mismatched types: expectedi64
, found&i64
(expected i64, found &-ptr) [E0308]Task2_minimalcode.rs:7 if (k % p != 0) {array.push(p)}; ^ error: aborting due to 2 previous errors Failed compilation.