fn item_bound_is_too_weak(b: bool) -> impl FnOnce() -> u32 {
if b {
let mut var = item_bound_is_too_weak(false);
println!("{}", var());
println!("{}", var());
}
let mut state = 0u32;
move || {
state += 1;
state
}
}
fn main() {
item_bound_is_too_weak(true);
}
this results in 1 1 because we unnecessarily assume the fn call to be FnOnce which then copies the closure. Should mention in the stabilization report and also... maybe lint when copying closures xd