use crate::compat::*; use super::traits::*; /// Wrapper struct for using pointer equality and hashes rather /// than pointed-to value equality and hashes. #[derive(Clone, Debug)] pub struct ByPtr(K); impl WeakElement for ByPtr { type Strong = K::Strong; fn new(view: &Self::Strong) -> Self { ByPtr(K::new(view)) } fn view(&self) -> Option { self.0.view() } } impl WeakKey for ByPtr where K::Strong: Deref { type Key = *const ::Target; fn with_key(view: &Self::Strong, f: F) -> R where F: FnOnce(&Self::Key) -> R { f(&(view.deref() as *const _)) } }