From 129c13c21254ca104bddf020170edaca1fb7107d Mon Sep 17 00:00:00 2001 From: Mica White Date: Wed, 25 Dec 2024 22:49:42 -0500 Subject: Implement common traits --- src/collection/guard.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/collection/guard.rs') diff --git a/src/collection/guard.rs b/src/collection/guard.rs index d604680..fc8df30 100644 --- a/src/collection/guard.rs +++ b/src/collection/guard.rs @@ -1,10 +1,37 @@ use std::fmt::{Debug, Display}; +use std::hash::Hash; use std::ops::{Deref, DerefMut}; use crate::key::Keyable; use super::LockGuard; +impl PartialEq for LockGuard<'_, Guard, Key> { + fn eq(&self, other: &Self) -> bool { + self.guard.eq(&other.guard) + } +} + +impl PartialOrd for LockGuard<'_, Guard, Key> { + fn partial_cmp(&self, other: &Self) -> Option { + self.guard.partial_cmp(&other.guard) + } +} + +impl Eq for LockGuard<'_, Guard, Key> {} + +impl Ord for LockGuard<'_, Guard, Key> { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.guard.cmp(&other.guard) + } +} + +impl Hash for LockGuard<'_, Guard, Key> { + fn hash(&self, state: &mut H) { + self.guard.hash(state) + } +} + impl Debug for LockGuard<'_, Guard, Key> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(&**self, f) -- cgit v1.2.3