I'm trying to retrieve the inner value of an Arc Mutex wrapper around an FLTK-RS Widget:
pub struct ArcWidget<T: Clone + WidgetExt + WidgetBase>(Arc<Mutex<T>>);
impl<T: Clone + WidgetExt + WidgetBase> ArcWidget<T>{
pub fn widg(&self)->T{
let lock = self.0.clone();
let lock2 = lock.into_inner().unwrap();
lock2
}
pub fn redraw(&self){
let mut widg = self.0.lock().unwrap();
widg.redraw();
}
}
However this results in error:
let lock = self.0.into_inner().unwrap().clone();
cannot move out of an `Arc` - move occurs because value has type `Mutex<T>`, which does not implement the `Copy` trait
I thought adding the Clone
trait restriction would solve this, but apparently it did not. How might I address this error? WidgetExt
+WidgetBase
are incompatible with Copy
, so I can not add a Copy
trait restriction.