Third-Party Import of: https://crates.io/crates/ptr_meta/0.2.0

Request Document: go/android3p
For CL Reviewers: go/android3p#reviewing-a-cl
For Build Team: go/ab-third-party-imports

Generated through these steps
(in ~src/android/aosp-main-future-without-vendor repo):
1. python3 development/scripts/get_rust_pkg.py -add3prf -v -o /tmp
   ptr_meta-0.2.0
2. cp -r /tmp/ptr_meta-0.2.0/* external/rust/crates/ptr_meta

Test: -
Bug: 375626569

Original import of the code can be found at: https://googleplex-android.googlesource.com/platform/external/rust/crates/ptr_meta/+/refs/heads/third-party-review.
Security Questionnaire: http://b/375626569#comment1

Change-Id: I433c929328b1863204c12a866ddd414f4f85732d
10 files changed
tree: e3716c104122c3d29575070ad0d924ac9d572e9d
  1. src/
  2. Cargo.toml
  3. Cargo.toml.orig
  4. crates-io.md
  5. LICENSE
  6. METADATA
  7. MODULE_LICENSE_MIT
  8. OWNERS
  9. README.md
README.md

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