diff --git a/src/impl_/cell_loop.rs b/src/impl_/cell_loop.rs index 941301a..40ac0ce 100644 --- a/src/impl_/cell_loop.rs +++ b/src/impl_/cell_loop.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use std::sync::Mutex; pub struct CellLoop { - pub init_value_op: Arc>>, + pub init_value_op: Arc>>>, pub stream_loop: StreamLoop, pub cell: Cell, } @@ -25,17 +25,17 @@ impl Clone for CellLoop { impl CellLoop { pub fn new(sodium_ctx: &SodiumCtx) -> CellLoop { - let init_value_op: Arc>> = Arc::new(Mutex::new(None)); + let init_value_op: Arc>>> = Arc::new(Mutex::new(None)); let init_value: Lazy; { let init_value_op = init_value_op.clone(); init_value = Lazy::new(move || { let mut l = init_value_op.lock(); - let init_value_op: &mut Option = l.as_mut().unwrap(); - let mut result_op: Option = None; + let init_value_op: &mut Option> = l.as_mut().unwrap(); + let mut result_op: Option> = None; mem::swap(&mut result_op, init_value_op); if let Some(init_value) = result_op { - return init_value; + return init_value.run(); } panic!("CellLoop sampled before looped."); }); @@ -56,7 +56,7 @@ impl CellLoop { pub fn loop_(&self, ca: &Cell) { self.stream_loop.loop_(&ca.updates()); let mut l = self.init_value_op.lock(); - let init_value_op: &mut Option = l.as_mut().unwrap(); - *init_value_op = Some(ca.sample()); + let init_value_op: &mut Option> = l.as_mut().unwrap(); + *init_value_op = Some(ca.sample_lazy()); } }