Consider something like this (https://play.rust-lang.org/?version=nightly&mode=debug):
struct Foo {}
impl Foo {
pub fn mut_void(&mut self, n : i32 ) -> () {}
pub fn mut_ret(&mut self) -> i32 { 42 }
}
fn main() {
let mut foo = Foo{};
// This is okay
let ret = foo.mut_ret();
foo.mut_void(ret);
// This is not okay
foo.mut_void( foo.mut_ret() );
}
The nested calls in the last line of main is not allowed because foo is borrowed as mutable twice. Naively i assumed that borrow in foo.mut_ret() would be “released” by the time foo.mut_void was called because mut_ret has to complete before the call to mut_void can be started.
Is there any particular reason the latter syntax is not allowed, or will it be allowed as part of the NLL changes i read about somewhere?