I am beginner in rust. I see pop()
method of vector returns <Option>
type. What the right way to get pop()
value to variable?
let mut queue: Vec<[usize; 2]> = Vec::new();
queue.push([1, 2]);
queue.push([3, 4]);
let coords = queue.pop();
println!("{}, {}", coords[0], coords[1]);
error[E0608]: cannot index into a value of type `std::option::Option<[usize; 2]>`
--> src/main.rs:99:24
|
99 | println!("{}, {}", coords[0], coords[1]);
|