[go: up one dir, main page]

dashmap 3.11.10

Blazing fast concurrent HashMap for Rust.
Documentation
use crate::mapref;
use ahash::RandomState;
use core::hash::{BuildHasher, Hash};
use core::ops::Deref;

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()
    }
}