Modify struct values in HashMap errors

I am getting those two errors when I tried to change the values in HashMap, I tried different ways, none worked. Not sure how to fix it.

error[E0594]: cannot assign to `` which is behind a `&` reference
  --> src/
73 | = "Yujio".to_string();
   |     ^^^^^^^ cannot assign

error[E0596]: cannot borrow `` as mutable, as it is behind a `&` reference
  --> src/
74 |"CEO".to_string());
   |     ^^^^^^^ cannot borrow as mutable
use std::collections::HashMap;

struct Person {
    name: String,
    jobs: Vec<String>,

fn get_person_map() -> HashMap<u32, Person> {
    let mut h = HashMap::new();
            Person { 
                name: "Mikya".to_string(),
                jobs: vec!["manager".to_string(), "VP".to_string()],
    return h;

fn main() {
    let mut h = get_person_map();
    let mut p1 = &mut h.get(&1).unwrap(); = "Yujio".to_string();"CEO".to_string());

You probably want h.get_mut, not &mut h.get - documentation.

@Cerber-Ursi , that worked, thank you!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.