impl Hash for MyType {
fn hash<H: Hasher>(&self, state: &mut H) {
self.name.hash(state);
}
}
fn my_fn(...) -> (Vec<MyType>, HashMap<key_type, &MyType>{
let mut my_vec: Vec<MyType> = ...construct vec...;
let my_hmap: HashMap<key_type, &MyType> = my_vec.par_iter().map(|n| n.name.clone(), n).collect();
(my_vec, my_hmap)
I get the following error:
fn my_fn(...) -> (Vec<MyType>, HashMap<key_type, &MyType>) {
^ expected named lifetime parameter
What I think I understand is that the referenced variable exists only in the function's scope, since I can build the hmap just fine within the function without returning it. But I don't know a solution. Thank you.