Xeno
1
I'm a bit confused regarding the ownership system and how it works with the parallel iterators in rayon. For example:
let x = 10;
(0..100).into_par_iter().for_each(|y| {
let z = x + y;
println!("{}", z);
println!("{}", x);
});
How is the ownership over x defined across multiple threads here??
bjorn3
2
The closure borrows from x. It doesn't own it.
1 Like
Xeno
3
So essentialy, x is passed as a reference into the closure?
Xeno
5
Many thanks!
This clears things up
system
Closed
6
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.