• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

src/25-Apr-2025-480267

Android.bpD25-Apr-202568 21

Cargo.tomlD25-Apr-2025946 3531

Cargo.toml.origD25-Apr-2025618 2218

LICENSED25-Apr-20251 KiB84

METADATAD25-Apr-2025406 2120

MODULE_LICENSE_MITD25-Apr-20250

OWNERSD25-Apr-202545 21

README.mdD25-Apr-20251.5 KiB5537

crates-io.mdD25-Apr-20251.2 KiB5234

README.md

1# ptr_meta   [![Latest Version]][crates.io] [![License]][license path] [![requires: rustc 1.47+]][Rust 1.47]
2
3[Latest Version]: https://img.shields.io/crates/v/ptr_meta.svg
4[crates.io]: https://crates.io/crates/ptr_meta
5[License]: https://img.shields.io/badge/license-MIT-blue.svg
6[license path]: https://github.com/djkoloski/ptr_meta/blob/master/LICENSE
7[requires: rustc 1.47+]: https://img.shields.io/badge/rustc-1.47+-lightgray.svg
8[Rust 1.47]: https://blog.rust-lang.org/2020/10/08/Rust-1.47.html
9
10# ptr_meta
11
12A radioactive stabilization of the [`ptr_meta` RFC][rfc].
13
14[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html
15
16## Usage
17
18### Sized types
19
20Sized types already have `Pointee` implemented for them, so most of the time you won't have to worry
21about them. However, trying to derive `Pointee` for a struct that may or may not have a DST as its
22last field will cause an implementation conflict with the automatic sized implementation.
23
24### `slice`s and `str`s
25
26These core types have implementations built in.
27
28### Structs with a DST as its last field
29
30You can derive `Pointee` for last-field DSTs:
31
32```rust
33use ptr_meta::Pointee;
34
35#[derive(Pointee)]
36struct Block<H, T> {
37    header: H,
38    elements: [T],
39}
40```
41
42### Trait objects
43
44You can generate a `Pointee` for trait objects:
45
46```rust
47use ptr_meta::pointee;
48
49// Generates Pointee for dyn Stringy
50#[pointee]
51trait Stringy {
52    fn as_string(&self) -> String;
53}
54```
55