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?
VecandVecDequedon't expose this method because it will always have to be anO(n)operation for these data structures. Maybe a different data structure would be more appropriate for your case? – Shepmaster Feb 23 '16 at 20:33Vecdoes exposecontains()through its deref to a slice: here. – Vladimir Matveev Feb 23 '16 at 20:41