mirror of https://github.com/xacrimon/dashmap
Implement Clone and Debug
This commit is contained in:
parent
0bdf2294c6
commit
dbff908801
|
@ -2,6 +2,7 @@ use crate::t::Map;
|
|||
use crate::{DashMap, HashMap};
|
||||
use ahash::RandomState;
|
||||
use std::borrow::Borrow;
|
||||
use std::fmt;
|
||||
use std::hash::{BuildHasher, Hash};
|
||||
|
||||
/// A read-only view into a `DashMap`. Allows to obtain raw references to the stored values.
|
||||
|
@ -9,6 +10,22 @@ pub struct ReadOnlyView<K, V, S = RandomState> {
|
|||
map: DashMap<K, V, S>,
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash + Clone, V: Clone, S: Clone> Clone for ReadOnlyView<K, V, S> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
map: self.map.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash + fmt::Debug, V: fmt::Debug, S: BuildHasher + Clone> fmt::Debug
|
||||
for ReadOnlyView<K, V, S>
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.map.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, S> ReadOnlyView<K, V, S> {
|
||||
#[inline]
|
||||
pub(crate) fn new(map: DashMap<K, V, S>) -> Self {
|
||||
|
|
Loading…
Reference in New Issue