[][src]Trait erasable::Erasable

pub unsafe trait Erasable {
    unsafe fn unerase(this: ErasedPtr) -> NonNull<Self>;

    fn erase(this: NonNull<Self>) -> ErasedPtr { ... }
}

A pointee type that supports type-erased pointers (thin pointers).

This trait is automatically implemented for all sized types, and can be manually implemented for unsized types that know their own metadata.

Required methods

unsafe fn unerase(this: ErasedPtr) -> NonNull<Self>

Unerase this erased pointer.

Note that this must be sound for erasable pointer types with both unique/write provenance and shared/read provenance. (In other words, both &mut _ and &_ can be unerased with this.)

Concretely, this means that the resulting pointer must be derived from the input pointer without any intervening references manifested. Temporary shared references may be used in the implementation, so long as the returned pointer is not derived from them.

Safety

The erased pointer must have been created by eraseing a valid pointer.

Loading content...

Provided methods

fn erase(this: NonNull<Self>) -> ErasedPtr

Turn this erasable pointer into an erased pointer.

To retrieve the original pointer, use unerase.

Loading content...

Implementors

impl<T: Sized> Erasable for T[src]

Loading content...