Consider the following:
use std::collections::HashMap;
use std::vec::Vec;
use crate::core::process_call_backs::SimpleCallback;
pub fn make_adventure_list(adventure_list: Vec<SimpleCallback>) -> HashMap<&i32, SimpleCallback> {
let mut adventures = HashMap::new();
let mut count = 1;
for adventure in adventure_list {
adventures.insert(count, adventure);
count = count + 1;
}
adventures;
}
I get the error:
error[E0106]: missing lifetime specifier
--> core/src/core/create_adventures.rs:5:76
|
5 | pub fn make_adventure_list(adventure_list: Vec<SimpleCallback>) -> HashMap<&i32, SimpleCallback> {
| ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
|
= help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
I understand the meaning of this error, but not I'm sure how to implement the fix. Do I need to make adventure_list
mutable?