pub fn try_lock(&self) -> Result<VaultAcquired<T>, ()> {
    let mut lock = self.inner.lock.lock();

    if !lock.locked {
      lock.locked = true;
      Ok(VaultAcquired {
        inner: self.inner.clone()
      })
    } else {
      Err(())
    }
  }
/// Trys to lock the `Vault` immediately. This function
/// is meant to be used outside of the futures API and
/// only when it is known that the `Vault` can be locked.
///
/// # Example
///
/// ```
/// # use popcorn::vault::*;
/// #
/// // Create a new Vault containing a double
/// let vault: Vault<f64> = Vault::new(34.5);
///
/// // Acquire the lock to the vault
/// let acquired = vault.try_lock().unwrap();
///
/// // Access the value in the vault
/// let value: f64 = *acquired;
/// #
/// # assert_eq!(value, 34.5);
/// ```
Trys to lock the `Vault` immediately. This function
is meant to be used outside of the futures API and
only when it is known that the `Vault` can be locked.
Trys to lock the ` Vault ` immediately . This function is meant to be used outside of the futures API and only when it is known that the ` Vault ` can be locked .
pub fn try_lock(&self) -> Result<VaultAcquired<T>, ()> {
    let mut lock = self.inner.lock.lock();
    if !lock.locked {
      lock.locked = true;
      Ok(VaultAcquired {
        inner: self.inner.clone()
      })
    } else {
      Err(())
    }
  }
pub fn try_lock ( & self ) -> Result < VaultAcquired < T > , ( ) > { let mut lock = self . inner . lock . lock ( ) ; if ! lock . locked { lock . locked = true ; Ok ( VaultAcquired { inner : self . inner . clone ( ) } ) } else { Err ( ( ) ) } }
Trys to lock the `Vault` immediately.
Trys to lock the ` Vault ` immediately .
&self
&self
example
None
use popcorn::vault::*;
Create a new Vault containing a double
let vault: Vault = Vault::new(34.5).

Acquire the lock to the vault
let acquired = vault.try_lock().unwrap().

Access the value in the vault
let value: f64 = *acquired.
Create a new Vault containing a double let vault : Vault = Vault :: new ( 34 . 5 ) . Acquire the lock to the vault let acquired = vault . try_lock () . unwrap () . Access the value in the vault let value : f64 = * acquired .
assert_eq!(value, 34.5);
None