Lifetime help on structure with hashmap

Hello, much appreciate for the help and time.

I am new to Rust, and trying to create a simple program to get me up and running with Rust
I tried to store structs to a hashmap and then later modify them through a method

here is the code I am playing around

if I change line 'from &mut self to &'a mut self the lifetime problem disappears, but I couldn't println! later, and another problem arises: could not borrow immutable because there is a mutable borrow

though I added the <'a> to the structs and methods, I don't quite understand how the contracts will be read...

how do we modify the lists with making the "permanent" borrow by &'a mut self?

thank you friends!

Classic self-referential struct. What you want cannot be done with references, but you can use Arc: Rust Playground

2 Likes

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.