Borrowing rules about self

If we look at this:

impl<'a> Member<'a> {
    fn modify_name(&'a mut self, name: &'a str) {
        self.name = name;
    }
}

The type of &mut self is &'a mut Member<'a>. When you call this method, it forces you to mutably borrow the Member<'a> for the lifetime 'a -- that's the entire lifetime of the data structure. Once you call this method, you'll never be able to do anything else with the data structure, because it will still be mutably (exclusively) borrowed.

In short, &'a mut Something<'a> is an anti-pattern you should avoid.

The fix is to accept a lifetime on &mut self that is shorter than 'a -- arbitrarily shorter. You can do this by simply leaving the 'a off of the &mut:

impl<'a> Member<'a> {
    fn modify_name(&mut self, name: &'a str) {
        self.name = name;
    }
}

Playground.


This is also true (but wasn't the source of your errors).