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
Currently the compiler needs a hint when it should move a value into a closure:
let consume = move || {//...};
Eventually, I think we do want to infer moving upvars but it might be difficult. I think there's already an issue for tracking this problem that explains it in more detail.
So move also is insufficient here - you wind up with the same error. However if you write
let n = Name(String::new());
let m = Name(String::new());
let consume = move || {
let m = m;
let Name(i) = n;
};
it will work, and yet fail ("error: cannot move out of captured outer variable in an FnOnce closure") without the move. It seems that the destructuring-let isn't included in figuring out it needs to be an FnOnce closure or something, /and/ the closure is missing move.
This should move
n
but it doesn't. It doesn't seem to infer it properly.Code:
Error:
The text was updated successfully, but these errors were encountered: