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

[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?

1 Like

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

Thanks for your feedback @sfackler!

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

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.