Closure body analysis how the values are used Value is not modifiedValue is modifiedValue is movedCapture:by immutable borrowCapture:by mutable borrowCapture:by move
letimmut_val = String::from("immut");
letfn_closure = || {
println!("Len: {}", immut_val.len());
};
let immut_val = String::from("immut");...
letmutmut_val = String::from("mut");
letmutfnmut_closure = || {
mut_val.push_str("-new");
};
let mut mut_val = String::from("mut");...
letmov_val = String::from("value");
letfnonce_closure = || {
letmoved_value = mov_val;
};
let mov_val = String::from("value");...Closure Trait:FnClosure Trait:FnMutClosure Trait:FnOnce
Other immutable references to the variable can live concurrently with the closure.
Other immutable references to th...
No other references to the variable can exist. Once the closure is dropped other references can exist again.
No other references to the varia...
The variable cannot be used by anything else ever again.