Crate erasable

source ·
Expand description

Erase pointers of their concrete type and store type-erased pointers.

This is roughly equivalent to C’s void*.

There are two main useful reasons to type erase pointers in Rust:

  • Removing viral generics from internal implementation details. If the internals truly don’t care about the stored type, treating it opaquely reduces monomorphization cost both to the author and the compiler.
  • Thin pointers to ?Sized types. If an unsized type stores its metadata inline, then it can implement Erasable and be used behind type-erased pointers. The type erased pointer does not have to carry the metadata, and the fat pointer can be recovered from the inline metadata. We provide the Thin wrapper type to provide thin pointer types.


Wrapper struct to create thin pointer types.


A pointee type that supports type-erased pointers (thin pointers).
A (smart) pointer type that can be type-erased (making a thin pointer).


Erase a pointer.

Type Definitions

A thin, type-erased pointer.