Skip to content

Commit

Permalink
Adjust Equivalent trait
Browse files Browse the repository at this point in the history
Note: It's a type inference break for the case of ``.remove(&&K)`` which
previously compiled (due to deref coercion?)
  • Loading branch information
bluss committed Nov 21, 2016
1 parent 36022c9 commit 43ec4fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ fn remove_ordermap_100_000(b: &mut Bencher) {
b.iter(|| {
let mut map = map.clone();
for key in &keys {
map.remove(&key).is_some();
map.remove(key).is_some();
}
assert_eq!(map.len(), 0);
map
Expand Down
4 changes: 2 additions & 2 deletions src/equivalent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ use std::borrow::Borrow;
/// # Contract
///
/// The implementor must hash like `K`, if applicable.
pub trait Equivalent<K: ?Sized> {
pub trait Equivalent<K> {
/// Compare self to `key` and return `true` if they are equal.
fn equivalent(&self, key: &K) -> bool;
}

impl<Q: ?Sized, K: ?Sized> Equivalent<K> for Q
impl<Q: ?Sized, K> Equivalent<K> for Q
where Q: Eq,
K: Borrow<Q>,
{
Expand Down
2 changes: 1 addition & 1 deletion tests/equivalent_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<A, B, C, D> PartialEq<(A, B)> for Pair<C, D>
}
}

impl<A, B, X: ?Sized> Equivalent<X> for Pair<A, B>
impl<A, B, X> Equivalent<X> for Pair<A, B>
where Pair<A, B>: PartialEq<X>,
A: Hash + Eq,
B: Hash + Eq,
Expand Down

0 comments on commit 43ec4fc

Please sign in to comment.