[−][src]Struct triomphe::ThinArc
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]
F: FnOnce(&Arc<HeaderSlice<HeaderWithLength<H>, [T]>>) -> U,
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]
I: Iterator<Item = T> + ExactSizeIterator,
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]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<H, T> Deref for ThinArc<H, T>
[src]
type Target = HeaderSlice<HeaderWithLength<H>, [T]>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
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]
fn hash<HSR: Hasher>(&self, state: &mut HSR)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<H: PartialEq, T: PartialEq> PartialEq<ThinArc<H, T>> for ThinArc<H, T>
[src]
fn eq(&self, other: &ThinArc<H, T>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[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,
H: RefUnwindSafe,
T: RefUnwindSafe,
impl<H, T> Unpin for ThinArc<H, T> where
H: Unpin,
T: Unpin,
H: Unpin,
T: Unpin,
impl<H, T> UnwindSafe for ThinArc<H, T> where
H: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
H: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,