Having a VecDeque
deq
and an item
, how can I find out if deq
contains item
? I can do it with an iterator:
deq.iter().find(|e| e == item).is_none()
But this is a lot of code. I just want to say deq.contains(item)
, but VecDeque
has no such method (edit: not true anymore, see my answer). Any alternatives?
In Rust 1.12 a contains
method was stabilized for LinkedList
and VecDeque
. Therefore the correct answer now is the obvious one:
deq.contains(item)