Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
src/ | 25-Apr-2025 | - | 480 | 267 | ||
Android.bp | D | 25-Apr-2025 | 68 | 2 | 1 | |
Cargo.toml | D | 25-Apr-2025 | 946 | 35 | 31 | |
Cargo.toml.orig | D | 25-Apr-2025 | 618 | 22 | 18 | |
LICENSE | D | 25-Apr-2025 | 1 KiB | 8 | 4 | |
METADATA | D | 25-Apr-2025 | 406 | 21 | 20 | |
MODULE_LICENSE_MIT | D | 25-Apr-2025 | 0 | |||
OWNERS | D | 25-Apr-2025 | 45 | 2 | 1 | |
README.md | D | 25-Apr-2025 | 1.5 KiB | 55 | 37 | |
crates-io.md | D | 25-Apr-2025 | 1.2 KiB | 52 | 34 |
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