-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a314707
commit efac0b9
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use std::borrow::Borrow; | ||
|
||
pub trait Equivalent<K: ?Sized> { | ||
fn equivalent(&self, key: &K) -> bool; | ||
} | ||
|
||
impl<Q: ?Sized, K: ?Sized> Equivalent<K> for Q | ||
where | ||
Q: Eq, | ||
K: Borrow<Q>, | ||
{ | ||
fn equivalent(&self, key: &K) -> bool { | ||
PartialEq::eq(self, key.borrow()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// exact-check | ||
|
||
// This test ensures that methods from blanket impls of not available foreign traits | ||
// don't show up in the search results. | ||
|
||
const EXPECTED = { | ||
'query': 'equivalent', | ||
'others': [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// aux-crate:priv:equivalent=equivalent.rs | ||
// compile-flags: -Zunstable-options --extern equivalent | ||
// edition:2018 | ||
|
||
extern crate equivalent; | ||
|
||
#[derive(Clone, PartialEq, Eq, Debug)] | ||
pub struct LayoutError; |