FromRawFamily

Trait FromRawFamily 

Source
pub trait FromRawFamily {
    type Pointer<T: ?Sized>;

    // Required method
    unsafe fn from_raw<T: ?Sized>(raw: *mut T) -> Self::Pointer<T>;
}

Required Associated Types§

Required Methods§

Source

unsafe fn from_raw<T: ?Sized>(raw: *mut T) -> Self::Pointer<T>

Create Pointer<T> from a raw pointer

After calling this method the raw pointer is owned by the resulting object. This means that the resulting object should clean up any resources associated with the pointer (such as memory).

§Safety

raw must be a pointer that is compatible with the resulting type. For example, if Pointer<T> is Box<T>, then raw must be a pointer to memory allocated as a Box. The exact requirements depend on the implementation.

Generally, the raw pointer must be the result of a previous call to into_raw on the corresponding type. This the case for types such as Box, Rc, and Arc. If the documentation for the implementation does not say otherwise, assume this is the case.

Additionally, this function takes ownership of the pointer. If raw or an alias thereof is used after calling this function it can potentially result in double-free, data races, or other undefined behavior.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl FromRawFamily for ArcFamily

Source§

type Pointer<T: ?Sized> = Arc<T>

Source§

impl FromRawFamily for BoxFamily

Source§

type Pointer<T: ?Sized> = Box<T>

Source§

impl FromRawFamily for ConstPtrFamily

Source§

impl FromRawFamily for MutPtrFamily

Source§

impl FromRawFamily for NonNullFamily

Source§

impl FromRawFamily for RcFamily

Source§

type Pointer<T: ?Sized> = Rc<T>

Source§

impl<P: FromRawFamily> FromRawFamily for OptionFromRawFamily<P>

§Safety

The input pointer must either be null (resulting in None), or be safe to convert into the inner pointer type.