Should be trivial, but can't see how to solve this borrow checker error

I'm quite ashamed because I can't solve this:

I think as_mut was what I need, but it gives me &mut &Data the 2nd & being the issue I believe, but how to get out of this situation?

Thanks for any help :slight_smile:

You would want to use get_mut instead of get. Additionally this requires you to make the lock mutable:

fn main() {    
    let mut all_data = DATA_TABLE.lock().unwrap();
    match all_data.get_mut(&0u64) {
        Some(data) => data.hash.clear(),
        None => (),

Use get_mut instead of get :slight_smile:

Edit: simultaneous answer :smiley:


Thanks to both of you, it was trivial indeed, but I was searching in Option doc and didn't though of looking in HashMap one… ^^' /ashamed

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.