summaryrefslogtreecommitdiff
path: root/rust/src/rc.rs
diff options
context:
space:
mode:
authorMichael Krasnitski <michael.krasnitski@gmail.com>2023-01-06 14:13:55 -0500
committerKyleMiles <krm504@nyu.edu>2023-01-06 18:04:05 -0500
commitad7f5293db22e23d8d50077aa99f5d7a904092fc (patch)
tree294217bc06b0cdc3a86ebdb1132ad8cddd02d5ce /rust/src/rc.rs
parentc97b7d878c048312257843ee585280cc07a906e7 (diff)
Rust API: Additional Cleanup
Diffstat (limited to 'rust/src/rc.rs')
-rw-r--r--rust/src/rc.rs11
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) }
}