Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloning iterators #278

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
8 changes: 6 additions & 2 deletions src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,13 @@ pub struct Iter<'a, K, V, S = RandomState, M = DashMap<K, V, S>> {
current: Option<GuardIter<'a, K, V, S>>,
}

impl<'i, K: Clone + Hash + Eq, V: Clone, S: Clone + BuildHasher> Clone for Iter<'i, K, V, S> {
impl<'i, K, V, S, M> Clone for Iter<'i, K, V, S, M> {
fn clone(&self) -> Self {
Iter::new(self.map)
Iter {
map: self.map,
shard_i: self.shard_i,
current: self.current.clone(),
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/iter_set.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::setref::multiple::RefMulti;
use crate::t::Map;
use crate::DashMap;
use core::hash::{BuildHasher, Hash};

pub struct OwningIter<K, S> {
Expand Down Expand Up @@ -34,10 +35,18 @@ where
{
}

pub struct Iter<'a, K, S, M> {
pub struct Iter<'a, K, S, M = DashMap<K, (), S>> {
inner: crate::iter::Iter<'a, K, (), S, M>,
}

impl<'i, K, S, M> Clone for Iter<'i, K, S, M> {
fn clone(&self) -> Self {
Iter {
inner: Clone::clone(&self.inner),
}
}
}

unsafe impl<'a, 'i, K, S, M> Send for Iter<'i, K, S, M>
where
K: 'a + Eq + Hash + Send,
Expand Down
Loading