Having an explicit partial borrow of self in the method signature would be useful under circumstances you need to mutably borrow a subset of the fields in self while having another active mutable borrow to self. Essentially, the borrow checker should only complain about multiple mutable borrows to self if the intersection between two partial mutable borrows of self's fields is not-empty.
struct Test {
val0: usize,
val1: usize,
val2: String
}
impl Test {
pub fn operation(self: &mut Self { val0, val1 }) -> &mut usize {
*val0 += 1;
*val1 += 1;
val0
}
pub fn concat(self: &mut Self { val0, val2 }) -> &mut String {
val2.push(format!("{}", *val0});
val2
}
}
What do you think?