This is a simplified version of what I'm trying to do.
struct Foo<'a> {
data: &'a str
}
impl<'a> Foo<'a> {
fn foo(&'a mut self) {
todo!()
}
fn bar(&'a mut self) {
todo!()
}
fn baz(&'a mut self) {
self.foo();
self.bar();
}
}
I'm trying to call two self mutating methods more than once the but it doesn't compile. What is wrong with this code? Why I should not call self mutating methods more than once?
Wrapping the code with unsafe{} didn't make the error go away. How to get around this error if I decide that I want to do the multiple self mutating calls anyway?