7 releases

0.3.0-pre1 Nov 4, 2023
0.3.0-alpha.2 Mar 30, 2024
0.2.0 Aug 10, 2022
0.1.4 Jul 9, 2021
0.1.1 Feb 19, 2021

#127 in #rfc

Download history 194186/week @ 2023-12-19 123965/week @ 2023-12-26 213999/week @ 2024-01-02 233540/week @ 2024-01-09 253387/week @ 2024-01-16 260772/week @ 2024-01-23 294479/week @ 2024-01-30 284415/week @ 2024-02-06 266433/week @ 2024-02-13 262427/week @ 2024-02-20 287471/week @ 2024-02-27 302944/week @ 2024-03-05 323288/week @ 2024-03-12 324872/week @ 2024-03-19 312203/week @ 2024-03-26 269143/week @ 2024-04-02

1,283,673 downloads per month
Used in 533 crates (via ptr_meta)

MIT license

5KB
96 lines

ptr_meta   Latest Version License

A radioactive stabilization of the ptr_meta RFC.

Usage

Sized types

All Sized types have Pointee implemented for them with a blanket implementation. You do not need to derive Pointee for these types.

slices and strs

These core types have implementations provided.

CStr and OsStr

These std types have implementations provided when the std feature is enabled.

dyn Any and dyn Error

These trait objects have implementations provided.

Structs with a DST as its last field

You can derive Pointee for structs with a trailing DST:

use ptr_meta::Pointee;

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

Note that this will only work when the last field is guaranteed to be a DST. Structs with a generic last field may have a conflicting blanket impl since the generic type may be Sized. In these cases, a collection of specific implementations may be required with the generic parameter set to a slice, str, or specific trait object.

Trait objects

You can generate a Pointee implementation for trait objects:

use ptr_meta::pointee;

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

Dependencies

~290–730KB
~18K SLoC