Trait 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 CStr

Source§

type Metadata = usize

Source§

impl Pointee for dyn Any

Source§

impl Pointee for dyn Any + Send

Source§

type Metadata = DynMetadata<dyn Any + Send>

Source§

impl Pointee for dyn Any + Send + Sync

Source§

type Metadata = DynMetadata<dyn Any + Sync + Send>

Source§

impl Pointee for dyn Any + Sync

Source§

type Metadata = DynMetadata<dyn Any + Sync>

Source§

impl Pointee for dyn Error

Source§

type Metadata = DynMetadata<dyn Error>

Source§

impl Pointee for dyn Error + Send

Source§

type Metadata = DynMetadata<dyn Error + Send>

Source§

impl Pointee for dyn Error + Send + Sync

Source§

type Metadata = DynMetadata<dyn Error + Sync + Send>

Source§

impl Pointee for dyn Error + Sync

Source§

type Metadata = DynMetadata<dyn Error + Sync>

Source§

impl Pointee for str

Source§

type Metadata = usize

Source§

impl<T> Pointee for [T]

Source§

type Metadata = usize

Implementors§

Source§

impl<T> Pointee for T