#[repr(transparent)]
pub struct OffsetArc<T> { /* private fields */ }
Expand description

An Arc, except it holds a pointer to the T instead of to the entire ArcInner.

An OffsetArc<T> has the same layout and ABI as a non-null const T* in C, and may be used in FFI function signatures.

 Arc<T>    OffsetArc<T>
  |          |
  v          v
 ---------------------
| RefCount | T (data) | [ArcInner<T>]
 ---------------------

This means that this is a direct pointer to its contained data (and can be read from by both C++ and Rust), but we can also convert it to a “regular” Arc<T> by removing the offset.

This is very useful if you have an Arc-containing struct shared between Rust and C++, and wish for C++ to be able to read the data behind the Arc without incurring an FFI call overhead.

Implementations

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

If uniquely owned, provide a mutable reference Else create a copy, and mutate that

This is functionally the same thing as Arc::make_mut

Clone it as an Arc

Produce a pointer to the data that can be converted back to an Arc

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
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

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.