Newbie here!
Suppose I have a mutable vec and if it contains any more than a certain number of elements, I would like to pop the last element and use it, otherwise I want to do something else. I can easily handle this with an unwrap() or an unreachable!(), but both feel weird since I know the vec can't possibly be empty, having just checked the length. Is there a better way to express this? Currently I am doing the following:
if my_vec.len() > 5 {
match my_vec.pop() {
Some(n) => do_something(n),
None => unreachable!(),
}
}
else{
//do something else
}