1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! This module contains the parallel iterator types for results
//! (`Result<T, E>`). You will rarely need to interact with it directly
//! unless you have need to name one of the iterator types.

use iter::*;
use iter::internal::*;

use option;

impl<T: Send, E> IntoParallelIterator for Result<T, E> {
    type Item = T;
    type Iter = IntoIter<T>;

    fn into_par_iter(self) -> Self::Iter {
        IntoIter { inner: self.ok().into_par_iter() }
    }
}

impl<'a, T: Sync, E> IntoParallelIterator for &'a Result<T, E> {
    type Item = &'a T;
    type Iter = Iter<'a, T>;

    fn into_par_iter(self) -> Self::Iter {
        Iter { inner: self.as_ref().ok().into_par_iter() }
    }
}

impl<'a, T: Send, E> IntoParallelIterator for &'a mut Result<T, E> {
    type Item = &'a mut T;
    type Iter = IterMut<'a, T>;

    fn into_par_iter(self) -> Self::Iter {
        IterMut { inner: self.as_mut().ok().into_par_iter() }
    }
}


delegate_indexed_iterator!{
    #[doc = "Parallel iterator over a result"]
    IntoIter<T> => option::IntoIter<T>,
    impl<T: Send>
}


delegate_indexed_iterator!{
    #[doc = "Parallel iterator over an immutable reference to a result"]
    Iter<'a, T> => option::IntoIter<&'a T>,
    impl<'a, T: Sync + 'a>
}


delegate_indexed_iterator!{
    #[doc = "Parallel iterator over a mutable reference to a result"]
    IterMut<'a, T> => option::IntoIter<&'a mut T>,
    impl<'a, T: Send + 'a>
}