summaryrefslogtreecommitdiffstats
path: root/third_party/rust/dashmap/src/setref
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/dashmap/src/setref')
-rw-r--r--third_party/rust/dashmap/src/setref/mod.rs2
-rw-r--r--third_party/rust/dashmap/src/setref/multiple.rs25
-rw-r--r--third_party/rust/dashmap/src/setref/one.rs29
3 files changed, 56 insertions, 0 deletions
diff --git a/third_party/rust/dashmap/src/setref/mod.rs b/third_party/rust/dashmap/src/setref/mod.rs
new file mode 100644
index 0000000000..95ae8f47f2
--- /dev/null
+++ b/third_party/rust/dashmap/src/setref/mod.rs
@@ -0,0 +1,2 @@
+pub mod multiple;
+pub mod one;
diff --git a/third_party/rust/dashmap/src/setref/multiple.rs b/third_party/rust/dashmap/src/setref/multiple.rs
new file mode 100644
index 0000000000..21e7ed4a70
--- /dev/null
+++ b/third_party/rust/dashmap/src/setref/multiple.rs
@@ -0,0 +1,25 @@
+use crate::mapref;
+use core::hash::{BuildHasher, Hash};
+use core::ops::Deref;
+use std::collections::hash_map::RandomState;
+pub struct RefMulti<'a, K, S = RandomState> {
+ inner: mapref::multiple::RefMulti<'a, K, (), S>,
+}
+
+impl<'a, K: Eq + Hash, S: BuildHasher> RefMulti<'a, K, S> {
+ pub(crate) fn new(inner: mapref::multiple::RefMulti<'a, K, (), S>) -> Self {
+ Self { inner }
+ }
+
+ pub fn key(&self) -> &K {
+ self.inner.key()
+ }
+}
+
+impl<'a, K: Eq + Hash, S: BuildHasher> Deref for RefMulti<'a, K, S> {
+ type Target = K;
+
+ fn deref(&self) -> &K {
+ self.key()
+ }
+}
diff --git a/third_party/rust/dashmap/src/setref/one.rs b/third_party/rust/dashmap/src/setref/one.rs
new file mode 100644
index 0000000000..ef03421563
--- /dev/null
+++ b/third_party/rust/dashmap/src/setref/one.rs
@@ -0,0 +1,29 @@
+use crate::mapref;
+use core::hash::{BuildHasher, Hash};
+use core::ops::Deref;
+use std::collections::hash_map::RandomState;
+pub struct Ref<'a, K, S = RandomState> {
+ inner: mapref::one::Ref<'a, K, (), S>,
+}
+
+unsafe impl<'a, K: Eq + Hash + Send, S: BuildHasher> Send for Ref<'a, K, S> {}
+
+unsafe impl<'a, K: Eq + Hash + Send + Sync, S: BuildHasher> Sync for Ref<'a, K, S> {}
+
+impl<'a, K: Eq + Hash, S: BuildHasher> Ref<'a, K, S> {
+ pub(crate) fn new(inner: mapref::one::Ref<'a, K, (), S>) -> Self {
+ Self { inner }
+ }
+
+ pub fn key(&self) -> &K {
+ self.inner.key()
+ }
+}
+
+impl<'a, K: Eq + Hash, S: BuildHasher> Deref for Ref<'a, K, S> {
+ type Target = K;
+
+ fn deref(&self) -> &K {
+ self.key()
+ }
+}