Struct containerof::OwnBox [] [src]

pub struct OwnBox<T> {
    // some fields omitted
}

Represent ownership of an object via ownership of an intrusive field within the object. Differs from Rust-standard Box<T> in that dropping an OwnBox<T> instance is a bug.

Methods

impl<T> OwnBox<T>

fn get_address(&self) -> usize

Get value pointer address.

unsafe fn from_alias(pointer: IntrusiveAlias) -> OwnBox<T>

Construct an OwnBox from an IntrusiveAlias pointer. Unsafe because this allows trivial construction of pointer aliases.

unsafe fn into_alias(self) -> IntrusiveAlias

Move ownership of an OwnBox into an IntrusiveAlias pointer. Unsafe because this allows trivial construction of pointer aliases.

unsafe fn as_alias<'a>(&'a self) -> &'a IntrusiveAlias

Return a borrow-pointer of an IntrusiveAlias with same address as the OwnBox. Unsafe because working with IntrusiveAlias structures (that is, raw pointers) is unsafe.

fn from_box(b: Box<T>) -> OwnBox<T>

Construct an OwnBox from a Box.

unsafe fn into_box(self) -> Box<T>

Construct a Box from an OwnBox. Should only be called on an OwnBox that was constructed via from_box (or convert::From>). Unsafe, because the OwnBox may not have been constructed from a Box, and if it hasn't, then dropping the resulting Box will result in an attempt to free an invalid pointer.

Trait Implementations

impl<T> From<Box<T>> for OwnBox<T>

fn from(t: Box<T>) -> OwnBox<T>

impl<T> Deref for OwnBox<T>

type Target = T

fn deref<'a>(&'a self) -> &'a T

impl<T> DerefMut for OwnBox<T>

fn deref_mut<'a>(&'a mut self) -> &'a mut T

impl<T> Drop for OwnBox<T>

fn drop(&mut self)