Open
Description
Using Vec::contains currently only works if the contains parameter is of the same &Type as the Vector elements. This means the parameter must be converted to the vec-item-type even though it is comparable with the type in the first place.
e.g. following code does not work, even though impl<'a, 'b> PartialEq<str> for String
exists:
fn main() {
let mut v: Vec<String> = Vec::new();
v.contains("mystring");
}
The Error:
error[E0308]: mismatched types
--> <anon>:3:16
|
3 | v.contains("mystring");
| ^^^^^^^^^^ expected struct `std::string::String`, found str
|
= note: expected type `&std::string::String`
found type `&'static str`
I'd be better if Vec::contains had definition like:
fn contains<U>(&self, value: &U) where T: PartialEq<U>, U: ?Sized