let session = valid_session(cookies);
let mut map = std::collections::HashMap::new();
match session {
None => {},
Some(s) => {
let user = s.user().clone();
map.insert("user", user.as_str());
},
};
map.insert("title", "Title");
Error:
|
56 | map.insert("user", user.as_str());
| ^^^^ borrowed value does not live long enough
57 | },
| - `user` dropped here while still borrowed
...
60 | map.insert("title", "Title");
| --- borrow later used here
Just trying to insert a str into a HashMap. Anyone know how to do it?