问题描述
我是初学者。我看到向量的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]);
error[E0608]: cannot index into a value of type `std::option::Option<[usize; 2]>`
--> src/main.rs:99:24
|
99 | println!("{},coords[1]);
|