[][src]Struct triomphe::ThinArc

#[repr(transparent)]pub struct ThinArc<H, T> { /* fields omitted */ }

A "thin" Arc containing dynamically sized data

This is functionally equivalent to Arc<(H, [T])>

When you create an Arc containing a dynamically sized type like HeaderSlice<H, [T]>, the Arc is represented on the stack as a "fat pointer", where the length of the slice is stored alongside the Arc's pointer. In some situations you may wish to have a thin pointer instead, perhaps for FFI compatibility or space efficiency.

Note that we use [T; 0] in order to have the right alignment for T.

ThinArc solves this by storing the length in the allocation itself, via HeaderSliceWithLength.

Implementations

impl<H, T> ThinArc<H, T>[src]

pub fn with_arc<F, U>(&self, f: F) -> U where
    F: FnOnce(&Arc<HeaderSlice<HeaderWithLength<H>, [T]>>) -> U, 
[src]

Temporarily converts |self| into a bonafide Arc and exposes it to the provided callback. The refcount is not modified.

pub fn from_header_and_iter<I>(header: H, items: I) -> Self where
    I: Iterator<Item = T> + ExactSizeIterator
[src]

Creates a ThinArc for a HeaderSlice using the given header struct and iterator to generate the slice.

pub fn ptr(&self) -> *const c_void[src]

Returns the address on the heap of the ThinArc itself -- not the T within it -- for memory reporting.

pub fn heap_ptr(&self) -> *const c_void[src]

Returns the address on the heap of the Arc itself -- not the T within it -- for memory reporting.

Trait Implementations

impl<H, T> Clone for ThinArc<H, T>[src]

impl<H, T> Deref for ThinArc<H, T>[src]

type Target = HeaderSlice<HeaderWithLength<H>, [T]>

The resulting type after dereferencing.

impl<H, T> Drop for ThinArc<H, T>[src]

impl<H: Eq, T: Eq> Eq for ThinArc<H, T>[src]

impl<H: Hash, T: Hash> Hash for ThinArc<H, T>[src]

impl<H: PartialEq, T: PartialEq> PartialEq<ThinArc<H, T>> for ThinArc<H, T>[src]

impl<H: Sync + Send, T: Sync + Send> Send for ThinArc<H, T>[src]

impl<H: Sync + Send, T: Sync + Send> Sync for ThinArc<H, T>[src]

Auto Trait Implementations

impl<H, T> RefUnwindSafe for ThinArc<H, T> where
    H: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<H, T> Unpin for ThinArc<H, T> where
    H: Unpin,
    T: Unpin
[src]

impl<H, T> UnwindSafe for ThinArc<H, T> where
    H: RefUnwindSafe + UnwindSafe,
    T: RefUnwindSafe + UnwindSafe
[src]

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.