rust/tests/rustdoc-js/auxiliary/equivalent.rs
2023-10-11 11:41:39 +02:00

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())
}
}