#[repr(transparent)]
pub struct ThinArc<H, T> { /* private fields */ }
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

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

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

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

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

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

Safety

Constructs an ThinArc from a raw pointer.

The raw pointer must have been previously returned by a call to ThinArc::into_raw.

The user of from_raw has to make sure a specific value of T is only dropped once.

This function is unsafe because improper use may lead to memory unsafety, even if the returned ThinArc is never accessed.

Consume ThinArc and returned the wrapped pointer.

Provides a raw pointer to the data. The counts are not affected in any way and the ThinArc is not consumed. The pointer is valid for as long as there are strong counts in the ThinArc.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.
Executes the destructor for this type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Formats the value using the given formatter.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.