Trait sp_std::ptr::Pointee[][src]

#[lang = "pointee_trait"]pub trait Pointee {
    type Metadata: Ord + Send + Copy + Sync + Unpin + Hash;
}
🔬 This is a nightly-only experimental API. (ptr_metadata)

Provides the pointer metadata type of any pointed-to type.

Pointer metadata

Raw pointer types and reference types in Rust can be thought of as made of two parts: a data pointer that contains the memory address of the value, and some metadata.

For statically-sized types (that implement the Sized traits) as well as for extern types, pointers are said to be “thin”: metadata is zero-sized and its type is ().

Pointers to dynamically-sized types are said to be “wide” or “fat”, they have non-zero-sized metadata:

In the future, the Rust language may gain new kinds of types that have different pointer metadata.

The Pointee trait

The point of this trait is its Metadata associated type, which is () or usize or DynMetadata<_> as described above. It is automatically implemented for every type. It can be assumed to be implemented in a generic context, even without a corresponding bound.

Usage

Raw pointers can be decomposed into the data address and metadata components with their to_raw_parts method.

Alternatively, metadata alone can be extracted with the metadata function. A reference can be passed to metadata and implicitly coerced.

A (possibly-wide) pointer can be put back together from its address and metadata with from_raw_parts or from_raw_parts_mut.

Associated Types

type Metadata: Ord + Send + Copy + Sync + Unpin + Hash[src]

🔬 This is a nightly-only experimental API. (ptr_metadata)

The type for metadata in pointers and references to Self.

Loading content...

Implementors

Loading content...