[−][src]Struct arc_swap::Lease
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][Lease::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> Sync for Lease<T> where
T: RefCnt + Send + Sync,
T::Base: Send + Sync, [src]
T: RefCnt + Send + Sync,
T::Base: Send + Sync,
impl<T> Send for Lease<T> where
T: RefCnt + Send + Sync,
T::Base: Send + Sync, [src]
T: RefCnt + Send + Sync,
T::Base: Send + Sync,
impl<T: RefCnt> Drop for Lease<T>[src]
impl<T> Display for Lease<T> where
T: NonNull,
T::Base: Display, [src]
T: NonNull,
T::Base: Display,
impl<T: NonNull> Deref for Lease<T>[src]
impl<T> Debug for Lease<T> where
T: RefCnt,
T::Base: Debug, [src]
T: RefCnt,
T::Base: Debug,
Blanket Implementations
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T> From for T[src]
impl<T, U> Into for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T> Borrow for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,