use std::cmp::Ordering; pub enum Item { Value { key: K, value: V }, Tomb(K), } impl Item { #[inline] fn key(&self) -> &K { match self { Self::Value { key, .. } | Self::Tomb(key) => key, } } } impl Ord for Item { #[inline] fn cmp(&self, other: &Self) -> Ordering { self.key().cmp(other.key()) } } impl PartialOrd for Item { #[inline] fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl PartialEq for Item { #[inline] fn eq(&self, other: &Self) -> bool { self.key() == other.key() } } impl Eq for Item {}