use std::fmt::{Debug, Display}; use std::hash::Hash; use std::ops::{Deref, DerefMut}; use super::{ConsumedIteratorGuard, IteratorGuard}; #[mutants::skip] // hashing involves RNG and is hard to test #[cfg(not(tarpaulin_include))] impl Hash for IteratorGuard<'_, Guard, Key> { fn hash(&self, state: &mut H) { self.guard.hash(state) } } // No implementations of Eq, PartialEq, PartialOrd, or Ord // You can't implement both PartialEq and PartialEq // It's easier to just implement neither and ask users to dereference // This is less of a problem when using the scoped lock API #[mutants::skip] #[cfg(not(tarpaulin_include))] impl Debug for IteratorGuard<'_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) } } impl Display for IteratorGuard<'_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&**self, f) } } impl Deref for IteratorGuard<'_, Guard, Key> { type Target = Guard; fn deref(&self) -> &Self::Target { &self.guard } } impl DerefMut for IteratorGuard<'_, Guard, Key> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.guard } } impl AsRef for IteratorGuard<'_, Guard, Key> { fn as_ref(&self) -> &Guard { &self.guard } } impl AsMut for IteratorGuard<'_, Guard, Key> { fn as_mut(&mut self) -> &mut Guard { &mut self.guard } }