Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/arbitrary.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use arbitrary::{Arbitrary, Unstructured};
use core::hash::BuildHasher;
use core::hash::{BuildHasher, Hash};

impl<'a, K, V, S> Arbitrary<'a> for crate::DashMap<K, V, S>
where
K: Eq + std::hash::Hash + Arbitrary<'a>,
K: Eq + Hash + Arbitrary<'a>,
V: Arbitrary<'a>,
S: Default + BuildHasher + Clone,
S: Default + BuildHasher,
{
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
u.arbitrary_iter()?.collect()
Expand Down
19 changes: 11 additions & 8 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use hashbrown::hash_table;
use super::mapref::multiple::{RefMulti, RefMutMulti};
use crate::lock::{RwLock, RwLockReadGuardDetached, RwLockWriteGuardDetached};
use crate::{DashMap, HashMap};
use core::hash::Hash;
use std::sync::Arc;

/// Iterator over a DashMap yielding key value pairs.
Expand All @@ -25,7 +24,7 @@ pub struct OwningIter<K, V> {
current: Option<GuardOwningIter<K, V>>,
}

impl<K: Eq + Hash, V> OwningIter<K, V> {
impl<K, V> OwningIter<K, V> {
pub(crate) fn new<S>(map: DashMap<K, V, S>) -> Self {
Self {
shards: map.shards.into_vec().into_iter(),
Expand All @@ -36,7 +35,7 @@ impl<K: Eq + Hash, V> OwningIter<K, V> {

type GuardOwningIter<K, V> = hash_table::IntoIter<(K, V)>;

impl<K: Eq + Hash, V> Iterator for OwningIter<K, V> {
impl<K, V> Iterator for OwningIter<K, V> {
type Item = (K, V);

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -79,7 +78,11 @@ pub struct Iter<'a, K, V> {
current: Option<GuardIter<'a, K, V>>,
}

impl<'i, K: Clone + Hash + Eq, V: Clone> Clone for Iter<'i, K, V> {
impl<'a, K, V> Clone for Iter<'a, K, V>
where
K: Clone,
V: Clone,
{
fn clone(&self) -> Self {
Iter {
shards: self.shards.clone(),
Expand All @@ -88,7 +91,7 @@ impl<'i, K: Clone + Hash + Eq, V: Clone> Clone for Iter<'i, K, V> {
}
}

impl<'a, K: Eq + Hash + 'a, V: 'a> Iter<'a, K, V> {
impl<'a, K, V> Iter<'a, K, V> {
pub(crate) fn new<S>(map: &'a DashMap<K, V, S>) -> Self {
Self {
shards: map.shards.iter(),
Expand All @@ -97,7 +100,7 @@ impl<'a, K: Eq + Hash + 'a, V: 'a> Iter<'a, K, V> {
}
}

impl<'a, K: Eq + Hash + 'a, V: 'a> Iterator for Iter<'a, K, V> {
impl<'a, K, V> Iterator for Iter<'a, K, V> {
type Item = RefMulti<'a, K, V>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -138,7 +141,7 @@ pub struct IterMut<'a, K, V> {
current: Option<GuardIterMut<'a, K, V>>,
}

impl<'a, K: Eq + Hash + 'a, V: 'a> IterMut<'a, K, V> {
impl<'a, K, V> IterMut<'a, K, V> {
pub(crate) fn new<S>(map: &'a DashMap<K, V, S>) -> Self {
Self {
shards: map.shards.iter(),
Expand All @@ -147,7 +150,7 @@ impl<'a, K: Eq + Hash + 'a, V: 'a> IterMut<'a, K, V> {
}
}

impl<'a, K: Eq + Hash + 'a, V: 'a> Iterator for IterMut<'a, K, V> {
impl<'a, K, V> Iterator for IterMut<'a, K, V> {
type Item = RefMutMulti<'a, K, V>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
9 changes: 4 additions & 5 deletions src/iter_set.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use crate::setref::multiple::RefMulti;
use core::hash::Hash;

pub struct OwningIter<K> {
inner: crate::iter::OwningIter<K, ()>,
}

impl<K: Eq + Hash> OwningIter<K> {
impl<K> OwningIter<K> {
pub(crate) fn new(inner: crate::iter::OwningIter<K, ()>) -> Self {
Self { inner }
}
}

impl<K: Eq + Hash> Iterator for OwningIter<K> {
impl<K> Iterator for OwningIter<K> {
type Item = K;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -23,13 +22,13 @@ pub struct Iter<'a, K> {
inner: crate::iter::Iter<'a, K, ()>,
}

impl<'a, K: Eq + Hash + 'a> Iter<'a, K> {
impl<'a, K> Iter<'a, K> {
pub(crate) fn new(inner: crate::iter::Iter<'a, K, ()>) -> Self {
Self { inner }
}
}

impl<'a, K: Eq + Hash + 'a> Iterator for Iter<'a, K> {
impl<'a, K> Iterator for Iter<'a, K> {
type Item = RefMulti<'a, K>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
Loading