]> git.proxmox.com Git - rustc.git/blob - vendor/rayon/src/collections/hash_set.rs
New upstream version 1.46.0~beta.2+dfsg1
[rustc.git] / vendor / rayon / src / collections / hash_set.rs
1 //! This module contains the parallel iterator types for hash sets
2 //! (`HashSet<T>`). You will rarely need to interact with it directly
3 //! unless you have need to name one of the iterator types.
4
5 use std::collections::HashSet;
6 use std::hash::{BuildHasher, Hash};
7
8 use crate::iter::plumbing::*;
9 use crate::iter::*;
10
11 use crate::vec;
12
13 /// Parallel iterator over a hash set
14 #[derive(Debug)] // std doesn't Clone
15 pub struct IntoIter<T: Hash + Eq + Send> {
16 inner: vec::IntoIter<T>,
17 }
18
19 into_par_vec! {
20 HashSet<T, S> => IntoIter<T>,
21 impl<T: Hash + Eq + Send, S: BuildHasher>
22 }
23
24 delegate_iterator! {
25 IntoIter<T> => T,
26 impl<T: Hash + Eq + Send>
27 }
28
29 /// Parallel iterator over an immutable reference to a hash set
30 #[derive(Debug)]
31 pub struct Iter<'a, T: Hash + Eq + Sync> {
32 inner: vec::IntoIter<&'a T>,
33 }
34
35 impl<'a, T: Hash + Eq + Sync> Clone for Iter<'a, T> {
36 fn clone(&self) -> Self {
37 Iter {
38 inner: self.inner.clone(),
39 }
40 }
41 }
42
43 into_par_vec! {
44 &'a HashSet<T, S> => Iter<'a, T>,
45 impl<'a, T: Hash + Eq + Sync, S: BuildHasher>
46 }
47
48 delegate_iterator! {
49 Iter<'a, T> => &'a T,
50 impl<'a, T: Hash + Eq + Sync + 'a>
51 }
52
53 // `HashSet` doesn't have a mutable `Iterator`