pub fn take(self) -> Result<T, AccessError> {
        // Safety: We know that interior value is alive since this container is
        // alive.
        //
        // Appropriate access is checked when constructing the guards.
        unsafe {
            let inner = self.inner.as_ref();

            // NB: don't drop guard to avoid yielding access back.
            // This will prevent the value from being dropped in the shared
            // destructor and future illegal access of any kind.
            let _ = ManuallyDrop::new(inner.access.take(AccessKind::Any)?);

            // Read the pointer out without dropping the inner structure.
            // The data field will be invalid at this point, which should be
            // flagged through a `taken` access flag.
            //
            // Future access is forever prevented since we never release
            // the access (see above).
            Ok(ptr::read(inner.data.get()))
        }
    }
/// Take the interior value, if we have exlusive access to it and there
/// are no other live exlusive or shared references.
///
/// A value that has been taken can no longer be accessed.
///
/// # Examples
///
/// ```rust
/// use runestick::Shared;
///
/// #[derive(Debug)]
/// struct Foo {
///     counter: isize,
/// }
///
/// let a = Shared::new(Foo { counter: 0 });
/// let b = a.clone();
///
/// {
///     let mut a = a.borrow_mut().unwrap();
///     // NB: this is prevented since we have a live reference.
///     assert!(b.take().is_err());
///     a.counter += 1;
/// }
///
/// let a = a.take().unwrap();
/// assert_eq!(a.counter, 1);
/// ```
Take the interior value, if we have exlusive access to it and there
are no other live exlusive or shared references.

A value that has been taken can no longer be accessed.
Take the interior value if we have exlusive access to it and there are no other live exlusive or shared references . A value that has been taken can no longer be accessed .
pub fn take(self) -> Result<T, AccessError> {
        // Safety: We know that interior value is alive since this container is
        // alive.
        //
        // Appropriate access is checked when constructing the guards.
        unsafe {
            let inner = self.inner.as_ref();
            // NB: don't drop guard to avoid yielding access back.
            // This will prevent the value from being dropped in the shared
            // destructor and future illegal access of any kind.
            let _ = ManuallyDrop::new(inner.access.take(AccessKind::Any)?);
            // Read the pointer out without dropping the inner structure.
            // The data field will be invalid at this point, which should be
            // flagged through a `taken` access flag.
            //
            // Future access is forever prevented since we never release
            // the access (see above).
            Ok(ptr::read(inner.data.get()))
        }
    }
pub fn take ( self ) -> Result < T , AccessError > { // Safety: We know that interior value is alive since this container is // alive. // // Appropriate access is checked when constructing the guards. unsafe { let inner = self . inner . as_ref ( ) ; // NB: don't drop guard to avoid yielding access back. // This will prevent the value from being dropped in the shared // destructor and future illegal access of any kind. let _ = ManuallyDrop :: new ( inner . access . take ( AccessKind :: Any ) ? ) ; // Read the pointer out without dropping the inner structure. // The data field will be invalid at this point, which should be // flagged through a `taken` access flag. // // Future access is forever prevented since we never release // the access (see above). Ok ( ptr :: read ( inner . data . get ( ) ) ) } }
Take the interior value, if we have exlusive access to it and there
are no other live exlusive or shared references.
Take the interior value if we have exlusive access to it and there are no other live exlusive or shared references .
self
self
examples
```rust
use runestick::Shared.
` ` ` rust use runestick :: Shared .
[derive(debug)]
struct Foo {
counter: isize,
}

let a = Shared::new(Foo { counter: 0 });
let b = a.clone().

{
let mut a = a.borrow_mut().unwrap();
NB: this is prevented since we have a live reference.


struct Foo { counter : isize } let a = Shared :: new ( Foo { counter : 0 } ) ; let b = a . clone () . { let mut a = a . borrow_mut () . unwrap () ; NB : this is prevented since we have a live reference .