You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error: cannot borrow `*f` as mutable more than once at a time
f(f(v))
^
note: previous borrow of `*f` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `*f` until the borrow ends
f(f(v))
^
note: previous borrow ends here
f(f(v))
^
error: cannot borrow `*f` as mutable more than once at a time
f(f(v))
^
note: previous borrow of `*f` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of `*f` until the borrow ends
f(f(v))
^
note: previous borrow ends here
f(f(v))
^
(The repetition is in the original.)
If I'm reading the notes here correctly, it seems that a call like closure(args...) borrows closure before evaluating args..., so that args... itself is not allowed to refer to closure. Is it really necessary to borrow closure so early? Can't we give the borrow a scope that starts after the arguments have been evaluated?
Yes, that's it exactly. Obviously [cough] this has nothing to do with closures; any nested method call that takes a &mut self will exhibit the same problem.
The following definition compiles fine:
whereas the more direct version does not:
The error we get here is:
(The repetition is in the original.)
If I'm reading the notes here correctly, it seems that a call like
closure(args...)
borrowsclosure
before evaluatingargs...
, so thatargs...
itself is not allowed to refer toclosure
. Is it really necessary to borrow closure so early? Can't we give the borrow a scope that starts after the arguments have been evaluated?Using: rustc 1.2.0-nightly (d6c8028 2015-06-09)
The text was updated successfully, but these errors were encountered: