Closed
Description
The following code is missing a cmp::Eq type constraint:
// rustc --lib equals.rs
type IMap<K: Copy, V: Copy> = ~[(K, V)];
trait ImmutableMap<K: Copy, V: Copy>
{
pure fn contains_key(key: K) -> bool;
}
impl<K: Copy, V: Copy> IMap<K, V> : ImmutableMap<K, V>
{
pure fn contains_key(key: K) -> bool
{
vec::find(self, |e| {e.first() == key}).is_some()
}
}
But the error is extremely confusing (and doesn't get any better if you split the code apart into multiple lines and add type annotations):
equals.rs:13:36: 13:39 error: mismatched types: expected `&const <V41>` but found `'a` (expected &-ptr but found type parameter)
equals.rs:13 vec::find(self, |e| {e.first() == key}).is_some()
^~~
equals.rs:13:23: 13:39 error: cannot determine a type for this bounded type parameter: unconstrained type
equals.rs:13 vec::find(self, |e| {e.first() == key}).is_some()
^~~~~~~~~~~~~~~~