Browse Source

Simplify the parallel Result with collect()

cl-test
Josh Stone 7 years ago
parent
commit
f95a268167
  1. 20
      src/lib.rs

20
src/lib.rs

@ -905,23 +905,11 @@ impl Build {
} }
} }
let results: Mutex<Vec<Result<(), Error>>> = Mutex::new(Vec::new());
objs.par_iter().with_max_len(1).for_each(
|obj| {
let res = self.compile_object(obj);
results.lock().unwrap().push(res)
},
);
// Check for any errors and return the first one found. // Check for any errors and return the first one found.
for result in results.into_inner().unwrap().iter() { objs.par_iter()
if result.is_err() { .with_max_len(1)
return result.clone(); .map(|obj| self.compile_object(obj))
} .collect()
}
Ok(())
} }
#[cfg(not(feature = "parallel"))] #[cfg(not(feature = "parallel"))]

Loading…
Cancel
Save