use std::ops::Deref;
use std::sync::{Arc, Mutex, MutexGuard};
struct Var {}
fn multithreading() -> Var {
let shared_var = Arc::new(Mutex::new(Var {}));
/*
multithreading job
*/
return *(shared_var.lock().unwrap().deref());
}
I'm defining a multi-threading function to operate on Var but this function doesn't compile and complaint:
error[E0507]: cannot move out of a shared reference
Is there any way to stop the sharing of shared_var and return the variable within?
Implementing trait Copy for Var may also solve the bug, but in my actual use case Var is too large to copy that I would prefer any other solution.