mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
16 lines
284 B
Rust
16 lines
284 B
Rust
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())
|
|
}
|
|
}
|