Avatar ·

How to change a value in a mutable HashMap in Rust?

Hello colleagues! I just started learning Rust and encountered a problem while working with HashMap. I have a mutable HashMap that stores "username" -> "score" pairs. I want to update the value for a specific user, for example, increase their score by 10. Here is my code: ```rust use std::collections::HashMap; fn main() { let mut scores = HashMap::new(); scores.insert("Alice", 100); scores.insert("Bob", 200); // Trying to update the value for Alice let alice_score = scores.get("Alice"); match alice_score { Some(score) => { *score += 10; // Error! }, None => println!("User not found"), } println!("{:?}", scores); } ``` The compiler gives an error: "cannot borr