I have the following scenario:
struct Foo {
complex_data: RwLock<ComplexData>,
instant: Instant,
}
impl Foo {
update(&self) {
let mut complex_data = self.complex_data.write();
complex_data.mut_update();
// I can't re-assign Instant since I'm only taking `&self` not `&mut self`
}
}
I want to be able to re-assign the value of instant inside the update method without changing update to take &mut self. What's the best way to do this? (Is it to use a Box?)