#ptr #meta #no-std

no-std ptr_meta

A radioactive stabilization of the ptr_meta rfc

5 releases

0.1.4 Jul 9, 2021
0.1.3 May 16, 2021
0.1.2 Mar 17, 2021
0.1.1 Feb 19, 2021
0.1.0 Feb 3, 2021

#66 in No standard library

Download history 127/week @ 2021-04-07 131/week @ 2021-04-14 412/week @ 2021-04-21 664/week @ 2021-04-28 468/week @ 2021-05-05 595/week @ 2021-05-12 747/week @ 2021-05-19 1174/week @ 2021-05-26 848/week @ 2021-06-02 846/week @ 2021-06-09 1554/week @ 2021-06-16 1748/week @ 2021-06-23 1820/week @ 2021-06-30 2734/week @ 2021-07-07 4008/week @ 2021-07-14 3649/week @ 2021-07-21

4,065 downloads per month
Used in 28 crates (3 directly)

MIT license

19KB
302 lines

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;
}

lib.rs:

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;
}

Dependencies

~325–750KB
~19K SLoC