Pre-RFC: add `contains` to `VecDeque`


#1

[T] has the method contains, Vec derefs to [T] and thus has it, too. VecDeque, using two slices internally, does not have a comparable method. I think that such a method should be added. Sure, there are other possibilities to check if a VecDeque contains a specific element (e.g. deq.iter().any(|e| e == item)). But contains expresses the intent in the method name, is shorter and (I would argue) more idiomatic.

Also see: http://stackoverflow.com/questions/35583148/check-if-vecdeque-contains-an-element

What do you think? Should I craft an RFC for this?


#2

I think this is a change that’s straightforward enough to just make a PR to add it (marked unstable initially).


#3

Thanks for your feedback @sfackler!

Submitted an RFC: https://github.com/rust-lang/rfcs/pull/1552