1use gc::{Finalize, Gc, GcCell, Trace};23#[derive(Clone, Trace, Finalize)]4pub struct FutureWrapper<V: Trace + 'static>(pub Gc<GcCell<Option<V>>>);5impl<T: Trace + 'static> FutureWrapper<T> {6 pub fn new() -> Self {7 Self(Gc::new(GcCell::new(None)))8 }9 pub fn fill(self, value: T) {10 assert!(self.0.borrow().is_none(), "wrapper is filled already");11 self.0.borrow_mut().replace(value);12 }13}14impl<T: Clone + Trace + 'static> FutureWrapper<T> {15 pub fn unwrap(&self) -> T {16 self.0.borrow().as_ref().cloned().unwrap()17 }18}1920impl<T: Trace + 'static> Default for FutureWrapper<T> {21 fn default() -> Self {22 Self::new()23 }24}