Simple syntax for parallel iterators in Rayon


Hello, Is there a way to reduce the syntax in the following loop of Rayon,

pub fn linear_dem_interparticle_force(
    d_x: &[f32], d_y: &[f32], d_z: &[f32], d_u: &[f32],
    d_v: &[f32], d_w: &[f32], d_omega_x: &[f32], d_omega_y: &[f32],
    d_omega_z: &[f32], d_rad: &[f32], d_fx: &mut [f32], d_fy: &mut [f32],
    d_fz: &mut [f32], d_tx: &mut [f32], d_ty: &mut [f32], d_tz: &mut [f32],
    d_tng_ctcs: &mut [Vec<HashMap<usize, TangCt>>],

    s_x: &[f32], s_y: &[f32], s_z: &[f32], s_u: &[f32],
    s_v: &[f32], s_w: &[f32], s_m: &[f32], s_omega_x: &[f32],
    s_omega_y: &[f32], s_omega_z: &[f32], s_dem_id:usize,
    s_nnps_id: usize,

    nnps: &NNPS,
    k_n: f32,
    eta_n: f32,
    k_t: f32,
    eta_t: f32,
    mu_f: f32,
    dt: f32,

) {
        .for_each(|(d_fx_i, (d_fy_i, (d_fz_i, (d_tx_i, (d_ty_i, (d_tz_i, (i, d_tng_ctcs_i)))))))| {
            let mut xij = Vector3::new(0., 0., 0.);
            let mut vij = Vector3::new(0., 0., 0.);
            let nbrs = match nnps.dim {
                1 => get_neighbours_1d(d_x[i], d_y[i], d_z[i], s_nnps_id, &nnps),
                2 => get_neighbours_2d(d_x[i], d_y[i], d_z[i], s_nnps_id, &nnps),
                3 => get_neighbours_3d(d_x[i], d_y[i], d_z[i], s_nnps_id, &nnps),
                _ => panic!("Dimensions are wrong"),

            for &j in nbrs.iter() {
                // Reset the forces for next contact
                fij_n[0] = 0.;
                fij_n[1] = 0.;
                // elided
            // elided

I want to zip all the mutable vectors in single zip method, if possible.


There’s an issue requesting something like itertools’ multizip, but nobody is working on it yet.