Guest User

Untitled

a guest
Jun 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. extern crate rayon;
  2.  
  3.  
  4. use std::error::Error;
  5. use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
  6.  
  7. fn long_computation(x: u32) -> Result<u32, Box<Error>> {
  8. Ok(41)
  9. }
  10.  
  11. fn main() {
  12.  
  13. let xs = vec![1, 2, 3, 4, 5, 6];
  14.  
  15. let results : Vec<Result<u32, Box<Error>>> = xs
  16. .par_iter()
  17. .map(|&x| Ok(long_computation(x)? + 1))
  18. .collect();
  19.  
  20. }
Add Comment
Please, Sign In to add comment