- Consider the folloiwng code:
pub struct Foo {}
impl Foo {
pub fn a(&mut self) -> i32 { panic!() }
pub fn b(&mut self) -> i32 { panic!() }
pub fn c(&mut self, x: i32, y: i32) -> i32 { panic!() }
}
pub fn test() {
let mut foo = Foo {};
{
let a = foo.a();
let b = foo.b();
let c = foo.c(a, b);
}
/*
{
foo.c( foo.a(), foo.b() );
}
*/
}
The commented out code does NOT compile. Why? In the above, if we explicitly call foo.a(), foo.b() and assign them to vars, everything works fine, so why does the commented out code have a "mut borrow" conflict?