我是 Rust 的初学者。我看到pop()向量返回<Option>类型的方法。获取pop()变量值的正确方法是什么?
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]);
Run Code Online (Sandbox Code Playgroud)
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]);
|
Run Code Online (Sandbox Code Playgroud)