Closed
Description
In code like this there’s some algorithm in place which makes the capture of variable x
by-value rather than the default by-ref:
fn main(){
let x = Some(vec![0]);
(||{
drop(x); // takes `x` by-value, therefore closure captures `x` by-value as well.
})()
}
However, x
will not be captured by-value when the x
is matched on in a moving manner:
fn main() {
let x = Some(vec![0]);
(|| {
match x { // cannot move out of captured outer variable in an `Fn` closure [E0507]
Some(x) => {}, // attempting to move value to here
None => {}
}
})()
}
It would be nice if the algorithm handled more cases (including one presented here).