diff options
Diffstat (limited to 'rust/src/rc.rs')
| -rw-r--r-- | rust/src/rc.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rust/src/rc.rs b/rust/src/rc.rs index 57deddc3..4ffecb3f 100644 --- a/rust/src/rc.rs +++ b/rust/src/rc.rs @@ -16,6 +16,7 @@ use std::borrow::Borrow; use std::fmt::{Debug, Display, Formatter}; +use std::hash::{Hash, Hasher}; use std::marker::PhantomData; use std::mem; use std::ops::{Deref, DerefMut}; @@ -118,7 +119,13 @@ impl<T: RefCountable + PartialEq> PartialEq for Ref<T> { } } -impl<T: RefCountable + PartialEq> Eq for Ref<T> {} +impl<T: RefCountable + Eq> Eq for Ref<T> {} + +impl<T: RefCountable + Hash> Hash for Ref<T> { + fn hash<H: Hasher>(&self, state: &mut H) { + self.contents.hash(state); + } +} // Guard provides access to a core-allocated resource whose // reference is held indirectly (e.g. a core-allocated array @@ -147,7 +154,7 @@ impl<'a, T> Guard<'a, T> where T: RefCountable, { - #[allow(clippy::should_implement_trait)] // This _is_ out own (lite) version of that trait + #[allow(clippy::should_implement_trait)] // This _is_ out own (lite) version of that trait pub fn clone(&self) -> Ref<T> { unsafe { <T as RefCountable>::inc_ref(&self.contents) } } |
