АГ
struct Foo;
impl Foo {
fn bar(&mut self, s: String) { }
fn baz(&mut self) -> String { … }
}
let mut foo = Foo;
foo.bar(foo.baz());
error[E0499]: cannot borrow `foo` as mutable more than once at a time
--> src/main.rs:9:13
|
9 | foo.bar(foo.baz());
| --- --- ^^^ second mutable borrow occurs here
| | |
| | first borrow later used by call
| first mutable borrow occurs here
error: aborting due to previous error
ведь аргументы раньше вызова функции вычисляются, значит и ссылки должны в том же порядке захватываться