A radioactive stabilization of the ptr_meta
RFC.
All Sized
types have Pointee
implemented for them with a blanket
implementation. You do not need to derive Pointee
for these types.
These core types have implementations provided.
These std types have implementations provided when the std
feature is
enabled.
These trait objects have implementations provided.
You can derive Pointee
for structs with a trailing DST:
use ptr_meta::Pointee;
#[derive(Pointee)]
struct Block<H, T> {
header: H,
elements: [T],
}
Note that this will only work when the last field is guaranteed to be a DST.
Structs with a generic last field may have a conflicting blanket impl since
the generic type may be Sized
. In these cases, a collection of specific
implementations may be required with the generic parameter set to a slice,
str
, or specific trait object.
You can generate a Pointee
implementation for trait objects:
use ptr_meta::pointee;
// Generates Pointee for dyn Stringy
#[pointee]
trait Stringy {
fn as_string(&self) -> String;
}