I have a large struct and want to check if some undoable operation is possible.
So, the code might be,
impl LargeStruct {
fn operate_something(&mut self) -> bool {}
fn undo_something(&mut self) {}
fn is_some_operation_possible(&mut self) -> bool { // I don't like this signature
if self.operate_something() {
self.undo_something();
true
} else {
false
}
}
}
I don’ want to contaminate signatures of methods using this test method with mut.
Copy and test is an alternative but suppose a situation that undo is much cheeper than copy.
Are there any ways to eliminate mut signature from this test method?