Coverage Report

Created: 2024-10-16 07:58

/rust/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.10.0/src/result.rs
Line
Count
Source (jump to first uncovered line)
1
//! Parallel iterator types for [results][std::result]
2
//!
3
//! You will rarely need to interact with this module directly unless you need
4
//! to name one of the iterator types.
5
//!
6
//! [std::result]: https://doc.rust-lang.org/stable/std/result/
7
8
use crate::iter::plumbing::*;
9
use crate::iter::*;
10
use std::sync::Mutex;
11
12
use crate::option;
13
14
/// Parallel iterator over a result
15
#[derive(Debug, Clone)]
16
pub struct IntoIter<T: Send> {
17
    inner: option::IntoIter<T>,
18
}
19
20
impl<T: Send, E> IntoParallelIterator for Result<T, E> {
21
    type Item = T;
22
    type Iter = IntoIter<T>;
23
24
    fn into_par_iter(self) -> Self::Iter {
25
        IntoIter {
26
            inner: self.ok().into_par_iter(),
27
        }
28
    }
29
}
30
31
delegate_indexed_iterator! {
32
    IntoIter<T> => T,
33
    impl<T: Send>
34
}
35
36
/// Parallel iterator over an immutable reference to a result
37
#[derive(Debug)]
38
pub struct Iter<'a, T: Sync> {
39
    inner: option::IntoIter<&'a T>,
40
}
41
42
impl<'a, T: Sync> Clone for Iter<'a, T> {
43
    fn clone(&self) -> Self {
44
        Iter {
45
            inner: self.inner.clone(),
46
        }
47
    }
48
}
49
50
impl<'a, T: Sync, E> IntoParallelIterator for &'a Result<T, E> {
51
    type Item = &'a T;
52
    type Iter = Iter<'a, T>;
53
54
    fn into_par_iter(self) -> Self::Iter {
55
        Iter {
56
            inner: self.as_ref().ok().into_par_iter(),
57
        }
58
    }
59
}
60
61
delegate_indexed_iterator! {
62
    Iter<'a, T> => &'a T,
63
    impl<'a, T: Sync + 'a>
64
}
65
66
/// Parallel iterator over a mutable reference to a result
67
#[derive(Debug)]
68
pub struct IterMut<'a, T: Send> {
69
    inner: option::IntoIter<&'a mut T>,
70
}
71
72
impl<'a, T: Send, E> IntoParallelIterator for &'a mut Result<T, E> {
73
    type Item = &'a mut T;
74
    type Iter = IterMut<'a, T>;
75
76
    fn into_par_iter(self) -> Self::Iter {
77
        IterMut {
78
            inner: self.as_mut().ok().into_par_iter(),
79
        }
80
    }
81
}
82
83
delegate_indexed_iterator! {
84
    IterMut<'a, T> => &'a mut T,
85
    impl<'a, T: Send + 'a>
86
}
87
88
/// Collect an arbitrary `Result`-wrapped collection.
89
///
90
/// If any item is `Err`, then all previous `Ok` items collected are
91
/// discarded, and it returns that error.  If there are multiple errors, the
92
/// one returned is not deterministic.
93
impl<C, T, E> FromParallelIterator<Result<T, E>> for Result<C, E>
94
where
95
    C: FromParallelIterator<T>,
96
    T: Send,
97
    E: Send,
98
{
99
139k
    fn from_par_iter<I>(par_iter: I) -> Self
100
139k
    where
101
139k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
139k
    {
103
139k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
593k
            move |item| match item {
105
593k
                Ok(item) => Some(item),
106
139k
                Err(error) => {
107
139k
                    // We don't need a blocking `lock()`, as anybody
108
139k
                    // else holding the lock will also be writing
109
139k
                    // `Some(error)`, and then ours is irrelevant.
110
139k
                    if let Ok(mut guard) = saved.try_lock() {
111
139k
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
139k
                    }
115
139k
                    None
116
139k
                }
117
593k
            }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<alloc::vec::Vec<u8>, wasmer_types::error::CompileError>::{closure#0}
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_compiler_llvm::object_file::CompiledFunction, wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
101k
            move |item| match item {
105
101k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
101k
            }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>::{closure#0}
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
51.5k
            move |item| match item {
105
51.5k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
51.5k
            }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
87.8k
            move |item| match item {
105
87.8k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
87.8k
            }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>::{closure#0}
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
18.8k
            move |item| match item {
105
18.8k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
18.8k
            }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
193k
            move |item| match item {
105
193k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
193k
            }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>::{closure#0}
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>::{closure#0}
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>::{closure#0}
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
51.5k
            move |item| match item {
105
51.5k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
51.5k
            }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>::{closure#0}
Line
Count
Source
104
87.8k
            move |item| match item {
105
87.8k
                Ok(item) => Some(item),
106
0
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
0
                    if let Ok(mut guard) = saved.try_lock() {
111
0
                        if guard.is_none() {
112
0
                            *guard = Some(error);
113
0
                        }
114
0
                    }
115
0
                    None
116
                }
117
87.8k
            }
118
139k
        }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<alloc::vec::Vec<u8>, wasmer_types::error::CompileError>
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_compiler_llvm::object_file::CompiledFunction, wasmer_types::error::CompileError>
Line
Count
Source
103
10.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
10.2k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>
Line
Count
Source
103
10.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
10.2k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>
Line
Count
Source
103
20.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
20.0k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>
Line
Count
Source
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
10.0k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>
Line
Count
Source
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
12.2k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>
Line
Count
Source
103
24.4k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
24.4k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>
Line
Count
Source
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
12.2k
        }
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>
Unexecuted instantiation: <core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>
Line
Count
Source
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
10.0k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>
Line
Count
Source
103
20.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
20.0k
        }
<core::result::Result<_, _> as rayon::iter::FromParallelIterator<core::result::Result<_, _>>>::from_par_iter::ok::<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>
Line
Count
Source
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
            move |item| match item {
105
                Ok(item) => Some(item),
106
                Err(error) => {
107
                    // We don't need a blocking `lock()`, as anybody
108
                    // else holding the lock will also be writing
109
                    // `Some(error)`, and then ours is irrelevant.
110
                    if let Ok(mut guard) = saved.try_lock() {
111
                        if guard.is_none() {
112
                            *guard = Some(error);
113
                        }
114
                    }
115
                    None
116
                }
117
            }
118
10.0k
        }
119
139k
120
139k
        let saved_error = Mutex::new(None);
121
139k
        let collection = par_iter
122
139k
            .into_par_iter()
123
139k
            .map(ok(&saved_error))
124
139k
            .while_some()
125
139k
            .collect();
126
139k
127
139k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
139k
            None => Ok(collection),
130
        }
131
139k
    }
Unexecuted instantiation: <core::result::Result<alloc::vec::Vec<alloc::vec::Vec<u8>>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<alloc::vec::Vec<u8>, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::chain::Chain<rayon::iter::chain::Chain<rayon::iter::map_with::MapInit<rayon::iter::par_bridge::IterBridge<wasmer_types::entity::iter::Iter<wasmer_types::indexes::LocalFunctionIndex, wasmer_compiler::translator::environ::FunctionBodyData>>, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#0}, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#1}>, rayon::iter::map_with::MapInit<rayon::iter::par_bridge::IterBridge<wasmer_types::entity::iter::Iter<wasmer_types::indexes::SignatureIndex, wasmer_types::types::FunctionType>>, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#2}, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#3}>>, rayon::iter::map_with::MapInit<rayon::iter::par_bridge::IterBridge<wasmer_types::entity::iter::Iter<wasmer_types::indexes::FunctionIndex, wasmer_types::indexes::SignatureIndex>>, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#4}, <wasmer_compiler_llvm::compiler::LLVMCompiler>::compile_native_object::{closure#5}>>>
<core::result::Result<alloc::vec::Vec<wasmer_compiler_llvm::object_file::CompiledFunction>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_compiler_llvm::object_file::CompiledFunction, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<(wasmer_types::indexes::LocalFunctionIndex, &wasmer_compiler::translator::environ::FunctionBodyData)>, <wasmer_compiler_llvm::compiler::LLVMCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#0}, <wasmer_compiler_llvm::compiler::LLVMCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#1}>>
Line
Count
Source
99
10.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.2k
    where
101
10.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.2k
    {
103
10.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.2k
            move |item| match item {
105
10.2k
                Ok(item) => Some(item),
106
10.2k
                Err(error) => {
107
10.2k
                    // We don't need a blocking `lock()`, as anybody
108
10.2k
                    // else holding the lock will also be writing
109
10.2k
                    // `Some(error)`, and then ours is irrelevant.
110
10.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.2k
                        if guard.is_none() {
112
10.2k
                            *guard = Some(error);
113
10.2k
                        }
114
10.2k
                    }
115
10.2k
                    None
116
10.2k
                }
117
10.2k
            }
118
10.2k
        }
119
10.2k
120
10.2k
        let saved_error = Mutex::new(None);
121
10.2k
        let collection = par_iter
122
10.2k
            .into_par_iter()
123
10.2k
            .map(ok(&saved_error))
124
10.2k
            .while_some()
125
10.2k
            .collect();
126
10.2k
127
10.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.2k
            None => Ok(collection),
130
        }
131
10.2k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<wasmer_types::types::FunctionType>, <wasmer_compiler_llvm::compiler::LLVMCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#5}, <wasmer_compiler_llvm::compiler::LLVMCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#6}>>
Line
Count
Source
99
10.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.2k
    where
101
10.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.2k
    {
103
10.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.2k
            move |item| match item {
105
10.2k
                Ok(item) => Some(item),
106
10.2k
                Err(error) => {
107
10.2k
                    // We don't need a blocking `lock()`, as anybody
108
10.2k
                    // else holding the lock will also be writing
109
10.2k
                    // `Some(error)`, and then ours is irrelevant.
110
10.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.2k
                        if guard.is_none() {
112
10.2k
                            *guard = Some(error);
113
10.2k
                        }
114
10.2k
                    }
115
10.2k
                    None
116
10.2k
                }
117
10.2k
            }
118
10.2k
        }
119
10.2k
120
10.2k
        let saved_error = Mutex::new(None);
121
10.2k
        let collection = par_iter
122
10.2k
            .into_par_iter()
123
10.2k
            .map(ok(&saved_error))
124
10.2k
            .while_some()
125
10.2k
            .collect();
126
10.2k
127
10.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.2k
            None => Ok(collection),
130
        }
131
10.2k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<wasmer_types::types::FunctionType>, <cranelift_frontend::frontend::FunctionBuilderContext>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#4}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<&wasmer_types::types::FunctionType>, <cranelift_frontend::frontend::FunctionBuilderContext>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#3}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>)>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<(wasmer_types::indexes::LocalFunctionIndex, &wasmer_compiler::translator::environ::FunctionBodyData)>, <wasmer_compiler_cranelift::translator::func_translator::FuncTranslator>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#2}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::section::CustomSection>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<wasmer_types::indexes::FunctionIndex>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#0}>>
Line
Count
Source
99
12.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
12.2k
    where
101
12.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
12.2k
    {
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
12.2k
            move |item| match item {
105
12.2k
                Ok(item) => Some(item),
106
12.2k
                Err(error) => {
107
12.2k
                    // We don't need a blocking `lock()`, as anybody
108
12.2k
                    // else holding the lock will also be writing
109
12.2k
                    // `Some(error)`, and then ours is irrelevant.
110
12.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
12.2k
                        if guard.is_none() {
112
12.2k
                            *guard = Some(error);
113
12.2k
                        }
114
12.2k
                    }
115
12.2k
                    None
116
12.2k
                }
117
12.2k
            }
118
12.2k
        }
119
12.2k
120
12.2k
        let saved_error = Mutex::new(None);
121
12.2k
        let collection = par_iter
122
12.2k
            .into_par_iter()
123
12.2k
            .map(ok(&saved_error))
124
12.2k
            .while_some()
125
12.2k
            .collect();
126
12.2k
127
12.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
12.2k
            None => Ok(collection),
130
        }
131
12.2k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<wasmer_types::types::FunctionType>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#3}>>
Line
Count
Source
99
12.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
12.2k
    where
101
12.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
12.2k
    {
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
12.2k
            move |item| match item {
105
12.2k
                Ok(item) => Some(item),
106
12.2k
                Err(error) => {
107
12.2k
                    // We don't need a blocking `lock()`, as anybody
108
12.2k
                    // else holding the lock will also be writing
109
12.2k
                    // `Some(error)`, and then ours is irrelevant.
110
12.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
12.2k
                        if guard.is_none() {
112
12.2k
                            *guard = Some(error);
113
12.2k
                        }
114
12.2k
                    }
115
12.2k
                    None
116
12.2k
                }
117
12.2k
            }
118
12.2k
        }
119
12.2k
120
12.2k
        let saved_error = Mutex::new(None);
121
12.2k
        let collection = par_iter
122
12.2k
            .into_par_iter()
123
12.2k
            .map(ok(&saved_error))
124
12.2k
            .while_some()
125
12.2k
            .collect();
126
12.2k
127
12.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
12.2k
            None => Ok(collection),
130
        }
131
12.2k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<&wasmer_types::types::FunctionType>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#2}>>
Line
Count
Source
99
12.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
12.2k
    where
101
12.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
12.2k
    {
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
12.2k
            move |item| match item {
105
12.2k
                Ok(item) => Some(item),
106
12.2k
                Err(error) => {
107
12.2k
                    // We don't need a blocking `lock()`, as anybody
108
12.2k
                    // else holding the lock will also be writing
109
12.2k
                    // `Some(error)`, and then ours is irrelevant.
110
12.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
12.2k
                        if guard.is_none() {
112
12.2k
                            *guard = Some(error);
113
12.2k
                        }
114
12.2k
                    }
115
12.2k
                    None
116
12.2k
                }
117
12.2k
            }
118
12.2k
        }
119
12.2k
120
12.2k
        let saved_error = Mutex::new(None);
121
12.2k
        let collection = par_iter
122
12.2k
            .into_par_iter()
123
12.2k
            .map(ok(&saved_error))
124
12.2k
            .while_some()
125
12.2k
            .collect();
126
12.2k
127
12.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
12.2k
            None => Ok(collection),
130
        }
131
12.2k
    }
<core::result::Result<alloc::vec::Vec<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>)>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<(wasmer_types::indexes::LocalFunctionIndex, &wasmer_compiler::translator::environ::FunctionBodyData)>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#1}>>
Line
Count
Source
99
12.2k
    fn from_par_iter<I>(par_iter: I) -> Self
100
12.2k
    where
101
12.2k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
12.2k
    {
103
12.2k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
12.2k
            move |item| match item {
105
12.2k
                Ok(item) => Some(item),
106
12.2k
                Err(error) => {
107
12.2k
                    // We don't need a blocking `lock()`, as anybody
108
12.2k
                    // else holding the lock will also be writing
109
12.2k
                    // `Some(error)`, and then ours is irrelevant.
110
12.2k
                    if let Ok(mut guard) = saved.try_lock() {
111
12.2k
                        if guard.is_none() {
112
12.2k
                            *guard = Some(error);
113
12.2k
                        }
114
12.2k
                    }
115
12.2k
                    None
116
12.2k
                }
117
12.2k
            }
118
12.2k
        }
119
12.2k
120
12.2k
        let saved_error = Mutex::new(None);
121
12.2k
        let collection = par_iter
122
12.2k
            .into_par_iter()
123
12.2k
            .map(ok(&saved_error))
124
12.2k
            .while_some()
125
12.2k
            .collect();
126
12.2k
127
12.2k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
12.2k
            None => Ok(collection),
130
        }
131
12.2k
    }
Unexecuted instantiation: <core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<wasmer_types::types::FunctionType>, <cranelift_frontend::frontend::FunctionBuilderContext>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#4}>>
Unexecuted instantiation: <core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<&wasmer_types::types::FunctionType>, <cranelift_frontend::frontend::FunctionBuilderContext>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#3}>>
Unexecuted instantiation: <core::result::Result<alloc::vec::Vec<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>)>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<gimli::write::cfi::FrameDescriptionEntry>), wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map_with::MapInit<rayon::slice::Iter<(wasmer_types::indexes::LocalFunctionIndex, &wasmer_compiler::translator::environ::FunctionBodyData)>, <wasmer_compiler_cranelift::translator::func_translator::FuncTranslator>::new, <wasmer_compiler_cranelift::compiler::CraneliftCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#2}>>
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::section::CustomSection>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::section::CustomSection, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<wasmer_types::indexes::FunctionIndex>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#0}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<wasmer_types::types::FunctionType>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#3}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<wasmer_types::compilation::function::FunctionBody>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<wasmer_types::compilation::function::FunctionBody, wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<&wasmer_types::types::FunctionType>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#2}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
<core::result::Result<alloc::vec::Vec<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>)>, wasmer_types::error::CompileError> as rayon::iter::FromParallelIterator<core::result::Result<(wasmer_types::compilation::function::CompiledFunction, core::option::Option<wasmer_compiler_singlepass::unwind::UnwindFrame>), wasmer_types::error::CompileError>>>::from_par_iter::<rayon::iter::map::Map<rayon::vec::IntoIter<(wasmer_types::indexes::LocalFunctionIndex, &wasmer_compiler::translator::environ::FunctionBodyData)>, <wasmer_compiler_singlepass::compiler::SinglepassCompiler as wasmer_compiler::compiler::Compiler>::compile_module::{closure#1}>>
Line
Count
Source
99
10.0k
    fn from_par_iter<I>(par_iter: I) -> Self
100
10.0k
    where
101
10.0k
        I: IntoParallelIterator<Item = Result<T, E>>,
102
10.0k
    {
103
10.0k
        fn ok<T, E>(saved: &Mutex<Option<E>>) -> impl Fn(Result<T, E>) -> Option<T> + '_ {
104
10.0k
            move |item| match item {
105
10.0k
                Ok(item) => Some(item),
106
10.0k
                Err(error) => {
107
10.0k
                    // We don't need a blocking `lock()`, as anybody
108
10.0k
                    // else holding the lock will also be writing
109
10.0k
                    // `Some(error)`, and then ours is irrelevant.
110
10.0k
                    if let Ok(mut guard) = saved.try_lock() {
111
10.0k
                        if guard.is_none() {
112
10.0k
                            *guard = Some(error);
113
10.0k
                        }
114
10.0k
                    }
115
10.0k
                    None
116
10.0k
                }
117
10.0k
            }
118
10.0k
        }
119
10.0k
120
10.0k
        let saved_error = Mutex::new(None);
121
10.0k
        let collection = par_iter
122
10.0k
            .into_par_iter()
123
10.0k
            .map(ok(&saved_error))
124
10.0k
            .while_some()
125
10.0k
            .collect();
126
10.0k
127
10.0k
        match saved_error.into_inner().unwrap() {
128
0
            Some(error) => Err(error),
129
10.0k
            None => Ok(collection),
130
        }
131
10.0k
    }
132
}