use std::borrow::Borrow; pub trait Equivalent { fn equivalent(&self, key: &K) -> bool; } impl Equivalent for Q where Q: Eq, K: Borrow, { fn equivalent(&self, key: &K) -> bool { PartialEq::eq(self, key.borrow()) } }