Hello, I am new to rust and am struggling to get my head around a few concepts. I understand the error of my code but dont really know how to fix it
use std::collections::HashMap;
// Lexical Analysis Errors
//
struct LexicalAnalyzer<'a> {
function_map: &'a mut HashMap<&'a str, &'a str>,
}
enum Tokens {
ParenthesisLeft,
ParenthesisRight,
Function,
Exponent,
Mul,
Div,
Add,
Sub,
Procedure(i32),
Number(i32),
}
impl<'a> LexicalAnalyzer<'a> {
fn clean(&mut self) {
self.function_map = self
.function_map
.iter_mut()
.map(|(name, function)| (*name, &function.replace(" ", "") as &str))
.collect::<HashMap<&str, &str>>();
}
the clean function is the source of the error. I want to mutate self.function_map