Add the rayon crate to Cargo.toml and call par_iter() on your collection to process data in parallel across multiple threads.
Add the rayon crate to your Cargo.toml and use the par_iter() method on your collection to process items in parallel.
[dependencies]
rayon = "1.10"
use rayon::prelude::*;
let data = vec![1, 2, 3, 4, 5];
let result: Vec<i32> = data.par_iter().map(|x| x * 2).collect();
Rayon is a tool that lets your Rust program use all your computer's processor cores at once to speed up work. Instead of processing a list of items one by one, it splits the list into chunks and handles them simultaneously. Think of it like hiring a team of workers to sort a pile of mail instead of doing it alone.