Hi ,i have working on pong game and try to make it work with rayon:
this works: self.my_vec_balls.par_iter_mut().for_each(|ball| ball.rect.translate(ball.vel));
this doesn't work: let par_iter_balls = self.my_vec_balls.par_iter_mut(); for ball in (self.my_vec_balls.par_iter_mut()): ball.rect.translate(ball.vel);
i have conditions for bouncing with walls but i have no idea how to insert condition inside for_each.
Your description is rather vague. It is entirely possible to include an if expression inside the closure you pass to for each. But you probably tried that already.