I used move in closure, and uc2: Send
But I can't make the both compiled
Saying uc2: !Sync........... why move
has no effect here? even in case of let x = uc2 can't make uc2 moved into the closure.
#[test]
fn a() {
use std::thread;
let mut uc = std::sync::Arc::new(std::cell::UnsafeCell::new(9));
let uc2 = uc.clone();
let j = thread::spawn(move || {
*uc2.get_mut() = 100;
});
j.join();
}
fn b() {
use std::thread;
let mut uc = std::sync::Arc::new(std::cell::UnsafeCell::new(9));
let uc2 = uc.clone();
let j = thread::spawn(move || {
let x = uc2;
*x.get_mut() = 100;
});
j.join();
}