Trait ptr_meta::Pointee

source ·
pub unsafe trait Pointee {
    type Metadata: Copy + Send + Sync + Ord + Hash + Unpin;
}
Expand description

A trait which associates pointer metadata with a pointee type.

§Pointer metadata

Pointers and references can be thought of as having two parts: a data address and some extra “pointer metadata”.

Pointers to statically-sized types and extern types are “narrow”: their pointer metadata is ().

Pointers to dynamically-sized types are “wide”: they have pointer metadata with a non-zero size. There are four classes of dynamically-sized types currently available:

  • strs have usize pointer metadata equal to the length of the string slice in bytes.
  • Slices like [i32] have usize pointer metadata equal to the length of the slice in items.
  • Trait objects like dyn SomeTrait have DynMetadata pointer metadata, which point to the trait objects’ virtual method tables.
  • Structs with a trailing DST have the same metadata as the trailing DST.

In the future, Rust may add new kinds of types which have different pointer metadata.

§Safety

The associated Metadata type must be the pointer metadata type for the implementing type.

Required Associated Types§

source

type Metadata: Copy + Send + Sync + Ord + Hash + Unpin

The metadata type for pointers and references to this type.

Implementations on Foreign Types§

source§

impl Pointee for str

source§

impl Pointee for CStr

source§

impl Pointee for OsStr

Available on crate feature std only.
source§

impl Pointee for dyn Any

source§

impl Pointee for dyn Any + Send

source§

impl Pointee for dyn Any + Send + Sync

source§

impl Pointee for dyn Any + Sync

source§

impl Pointee for dyn Error

source§

impl Pointee for dyn Error + Send

source§

impl Pointee for dyn Error + Send + Sync

source§

impl Pointee for dyn Error + Sync

source§

impl<T> Pointee for [T]

Implementors§

source§

impl<T> Pointee for T