I have a question about closre capture rules.
Document says:
Capture modes
The compiler prefers to capture a closed-over variable by immutable borrow, followed by unique immutable borrow (see below), by mutable borrow, and finally by move. It will pick the first choice of these that allows the closure to compile.
While, the following fn a() does not compiles, seems compiler prefer using mutable borrow instread of move. That is conflict with document:
it will pick the first choice of these that allows the closure to compile.
While, if I use another let uu = uc; in fn b() then compiler will use move.
I don't know why fn a() can't compiles just like fn b().
#[test]
fn a() {
let mut uc = UnsafeCell::new(9);
let j = thread::spawn(|| {
*uc.get_mut() = 100;
});
j.join();
}
#[test]
fn b() {
use std::cell::UnsafeCell;
let mut uc = UnsafeCell::new(9);
let j = thread::spawn(|| {
let mut uu = uc;
*uu.get_mut() = 100;
});
j.join();
}