• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! This module contains the parallel iterator types for linked lists
2 //! (`LinkedList<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::LinkedList;
6 
7 use crate::iter::plumbing::*;
8 use crate::iter::*;
9 
10 use crate::vec;
11 
12 /// Parallel iterator over a linked list
13 #[derive(Debug, Clone)]
14 pub struct IntoIter<T: Send> {
15     inner: vec::IntoIter<T>,
16 }
17 
18 into_par_vec! {
19     LinkedList<T> => IntoIter<T>,
20     impl<T: Send>
21 }
22 
23 delegate_iterator! {
24     IntoIter<T> => T,
25     impl<T: Send>
26 }
27 
28 /// Parallel iterator over an immutable reference to a linked list
29 #[derive(Debug)]
30 pub struct Iter<'a, T: Sync> {
31     inner: vec::IntoIter<&'a T>,
32 }
33 
34 impl<'a, T: Sync> Clone for Iter<'a, T> {
clone(&self) -> Self35     fn clone(&self) -> Self {
36         Iter {
37             inner: self.inner.clone(),
38         }
39     }
40 }
41 
42 into_par_vec! {
43     &'a LinkedList<T> => Iter<'a, T>,
44     impl<'a, T: Sync>
45 }
46 
47 delegate_iterator! {
48     Iter<'a, T> => &'a T,
49     impl<'a, T: Sync + 'a>
50 }
51 
52 /// Parallel iterator over a mutable reference to a linked list
53 #[derive(Debug)]
54 pub struct IterMut<'a, T: Send> {
55     inner: vec::IntoIter<&'a mut T>,
56 }
57 
58 into_par_vec! {
59     &'a mut LinkedList<T> => IterMut<'a, T>,
60     impl<'a, T: Send>
61 }
62 
63 delegate_iterator! {
64     IterMut<'a, T> => &'a mut T,
65     impl<'a, T: Send + 'a>
66 }
67