4 releases

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

#649 in Rust patterns

Download history 7916/week @ 2021-10-03 8060/week @ 2021-10-10 8869/week @ 2021-10-17 8749/week @ 2021-10-24 8785/week @ 2021-10-31 11810/week @ 2021-11-07 14190/week @ 2021-11-14 9588/week @ 2021-11-21 10331/week @ 2021-11-28 10545/week @ 2021-12-05 14624/week @ 2021-12-12 9123/week @ 2021-12-19 4772/week @ 2021-12-26 19892/week @ 2022-01-02 24705/week @ 2022-01-09 22273/week @ 2022-01-16

71,777 downloads per month
Used in 70 crates (via ptr_meta)

MIT license

4KB
63 lines

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

Dependencies

~280–700KB
~17K SLoC

`