pub fn with<O, F: FnOnce(&T) -> O>(&self, f: F) -> O {
    {
      let val_opt = self.val.read();
      if let Some(val) = val_opt.as_ref() {
        return f(val);
      }
    }
    let mut val_write_opt = self.val.write();
    if val_write_opt.as_ref().is_none() {
      *val_write_opt = Some((self.make)())
    }
    f(val_write_opt.as_ref().unwrap())
  }
///
/// Execute f with the value in the Resettable.
/// May lazily initialize the value in the Resettable.
///
/// TODO Explore the use of parking_lot::RWLock::upgradable_read
/// to avoid reacquiring the lock for initialization.
/// This can be used if we are sure that a deadlock won't happen
/// when two readers are trying to upgrade at the same time.
///
Execute f with the value in the Resettable.
May lazily initialize the value in the Resettable.


Execute f with the value in the Resettable . May lazily initialize the value in the Resettable .
pub fn with<O, F: FnOnce(&T) -> O>(&self, f: F) -> O {
    {
      let val_opt = self.val.read();
      if let Some(val) = val_opt.as_ref() {
        return f(val);
      }
    }
    let mut val_write_opt = self.val.write();
    if val_write_opt.as_ref().is_none() {
      *val_write_opt = Some((self.make)())
    }
    f(val_write_opt.as_ref().unwrap())
  }
pub fn with < O , F : FnOnce ( & T ) -> O > ( & self , f : F ) -> O { { let val_opt = self . val . read ( ) ; if let Some ( val ) = val_opt . as_ref ( ) { return f ( val ) ; } } let mut val_write_opt = self . val . write ( ) ; if val_write_opt . as_ref ( ) . is_none ( ) { * val_write_opt = Some ( ( self . make ) ( ) ) } f ( val_write_opt . as_ref ( ) . unwrap ( ) ) }
Execute f with the value in the Resettable.
Execute f with the value in the Resettable .
&self
f
F