I am trying to fold a rayon iterator into a HashMap<usize,String> but the only thing i can get is a Fold struct which i can make of no use
You want ParallelIterator::collect
to create the HashMap
I tried that but seems it is not implemented for HashMap<usize,String>
Can you show us your code? Because this works:
fn main() {
let hash_map: HashMap<usize, String> = vec![(0, "test".to_string())].into_par_iter().collect();
dbg!(hash_map);
}
2 Likes
Collect should be the easiest, but for general fold
do see its docs for an explanation how and why it is different than Iterator::fold
.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.