Bug: 375626569

Clone this repo:
  1. 84f9544 Migrate 9 newly imported crates to monorepo am: 4dc2762c1a by James Farrell · 7 weeks ago main
  2. 4dc2762 Migrate 9 newly imported crates to monorepo by James Farrell · 7 weeks ago
  3. cbf193c ptr_meta: Add no_std variant am: 8cedf65b82 by Nikolina Ilic · 9 weeks ago
  4. 8cedf65 ptr_meta: Add no_std variant by Nikolina Ilic · 9 weeks ago
  5. dd18921 Merge remote-tracking branch 'origin/upstream' am: 61a465c333 by Frank Piva · 10 weeks ago

ptr_meta   Latest Version License requires: rustc 1.47+

ptr_meta

A radioactive stabilization of the ptr_meta RFC.

Usage

Sized types

Sized types already have Pointee implemented for them, so most of the time you won't have to worry about them. However, trying to derive Pointee for a struct that may or may not have a DST as its last field will cause an implementation conflict with the automatic sized implementation.

slices and strs

These core types have implementations built in.

Structs with a DST as its last field

You can derive Pointee for last-field DSTs:

use ptr_meta::Pointee;

#[derive(Pointee)]
struct Block<H, T> {
    header: H,
    elements: [T],
}

Trait objects

You can generate a Pointee for trait objects:

use ptr_meta::pointee;

// Generates Pointee for dyn Stringy
#[pointee]
trait Stringy {
    fn as_string(&self) -> String;
}