I'm new to Rust and I keep getting errors relating to vectors, when I try running
use std::io;
use std::ops::Index;
fn main() {
let mut mem = vec![0];
let allocated: u16 = 255;
for i in 0..=allocated {
mem.push(0);
}
let mut inp = String::new();
println!(":)");
io::stdin()
.read_line(&mut inp)
.expect("cannot read");
let tape = inp.split("").collect::<Vec<_>>();
for iu16 in 0..=tape.len() {
tape[i] // issue
}
}
it returns
error[E0425]: cannot find value `i` in this scope
--> src\main.rs:22:14
|
22 | tape[i]
| ^ not found in this scope
warning: unused import: `std::ops::Index`
--> src\main.rs:4:5
|
4 | use std::ops::Index;
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
For more information about this error, try `rustc --explain E0425`.
warning: `bf` (bin "bf") generated 1 warning
error: could not compile `bf` (bin "bf") due to 1 previous error; 1 warning emitted
how do I fix this?