Q. What is the output of this code?
Code:
fn main() {
let x = vec![1, 2, 3];
println!("{}", x[1]);
}
β
Correct Answer: (B)
2
Explanation: Indexing starts at 0, so x[1] is 2.