[][src]Struct arc_swap::Lease

pub struct Lease<T: RefCnt> { /* fields omitted */ }

A temporary storage of the pointer.

This, unlike Guard, does not block any write operations and is usually faster than loading the full Arc. However, this holds only if each thread keeps only small number of Leases around and if too many are held, the following ones will just fall back to creating the Arc internally.

Methods

impl<T: RefCnt> Lease<T>[src]

pub fn upgrade(lease: &Self) -> T[src]

Loads a full Arc from the lease.

pub fn into_upgrade(lease: Self) -> T[src]

A consuming version of upgrade.

This is a bit faster in certain situations, but consumes the lease.

pub fn get_ref(lease: &Self) -> Option<&T::Base>[src]

Returns access to the data held.

This returns Option even when it can't hold NULL internally, to keep the interface the same. But there's also the Deref trait for the non-NULL cases, which is usually more comfortable.

pub fn is_null(lease: &Self) -> bool[src]

Checks if it contains a null pointer.

Note that for non-NULL T, this always returns false.

impl<T: NonNull> Lease<Option<T>>[src]

pub fn expect(self, msg: &str) -> Lease<T>[src]

Like unwrap, but with a panic message.

Panics

If the lease contains a NULL pointer.

pub fn unwrap(self) -> Lease<T>[src]

Asserts the lease contains non-NULL content and gets direct access to it.

This is very much like Option::unwrap.

Panics

If the lease contains a NULL pointer.

pub fn into_option(self) -> Option<Lease<T>>[src]

Transposes the Lease<Option<RefCnt>> into Option<Lease<RefCnt>>.

Examples

let shared = ArcSwapOption::from_pointee(42);
if let Some(ptr) = shared.lease().into_option() {
    println!("It is {}", ptr);
} else {
    println!("Nothing present");
}

Trait Implementations

impl<'a, T: RefCnt> AsRaw<<T as RefCnt>::Base> for &'a Lease<T>[src]

impl<T: RefCnt> AsRaw<<T as RefCnt>::Base> for Lease<T>[src]

impl<T> Send for Lease<T> where
    T: RefCnt + Send + Sync,
    T::Base: Send + Sync
[src]

impl<T> Sync for Lease<T> where
    T: RefCnt + Send + Sync,
    T::Base: Send + Sync
[src]

impl<T: RefCnt> Drop for Lease<T>[src]

impl<T> Display for Lease<T> where
    T: NonNull,
    T::Base: Display
[src]

impl<T: NonNull> Deref for Lease<T>[src]

type Target = T::Base

The resulting type after dereferencing.

impl<T> Debug for Lease<T> where
    T: RefCnt,
    T::Base: Debug
[src]

Blanket Implementations

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.