Struct triomphe::ThinArc [−][src]
#[repr(transparent)]pub struct ThinArc<H, T> { /* fields omitted */ }
Expand description
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
pub fn with_arc<F, U>(&self, f: F) -> U where
F: FnOnce(&Arc<HeaderSlice<HeaderWithLength<H>, [T]>>) -> U, [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]
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.
Returns the address on the heap of the ThinArc itself – not the T within it – for memory reporting.
Trait Implementations
Auto Trait Implementations
impl<H, T> RefUnwindSafe for ThinArc<H, T> where
H: RefUnwindSafe,
T: RefUnwindSafe, impl<H, T> UnwindSafe for ThinArc<H, T> where
H: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe, Blanket Implementations
Mutably borrows from an owned value. Read more