How to use rayon crate in Rust parallelism

Add rayon to Cargo.toml and use par_iter() to run collection operations in parallel across CPU cores.

Add the rayon crate to your Cargo.toml and use par_iter() to process collections in parallel.

[dependencies]
rayon = "1.10"
use rayon::prelude::*;

fn main() {
    let v: Vec<i32> = (0..100).collect();
    let sum: i32 = v.par_iter().sum();
    println!("Sum: {}", sum);
}

This replaces standard iterators with parallel ones, automatically distributing work across available CPU cores.