Skip to content

Commit

Permalink
Release 0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Aug 10, 2022
1 parent 7c10669 commit 61c9ccd
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 117 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ A radioactive stabilization of the [`ptr_meta` RFC][rfc].

[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html

## Usage
# Usage

### Sized types
## 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.
All `Sized` types have `Pointee` implemented for them with a blanket implementation. You do not
need to derive `Pointee` for these types.

### `slice`s and `str`s
## `slice`s and `str`s

These core types have implementations built in.

### Structs with a DST as its last field
# `dyn Any`

You can derive `Pointee` for last-field DSTs:
The trait object for this standard library type comes with an implementation built in.

## Structs with a DST as its last field

You can derive `Pointee` for structs with a trailing DST:

```rust
use ptr_meta::Pointee;
Expand All @@ -39,9 +42,14 @@ struct Block<H, T> {
}
```

### Trait objects
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` for trait objects:
You can generate a `Pointee` implementation for trait objects:

```rust
use ptr_meta::pointee;
Expand Down
4 changes: 2 additions & 2 deletions ptr_meta/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ptr_meta"
version = "0.1.4"
version = "0.2.0"
authors = ["David Koloski <[email protected]>"]
edition = "2018"
description = "A radioactive stabilization of the ptr_meta rfc"
Expand All @@ -14,7 +14,7 @@ readme = "crates-io.md"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ptr_meta_derive = { version = "=0.1.4", path = "../ptr_meta_derive" }
ptr_meta_derive = { version = "=0.2.0", path = "../ptr_meta_derive" }

[features]
default = ["std"]
Expand Down
30 changes: 18 additions & 12 deletions ptr_meta/crates-io.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# ptr_meta

A radioactive stabilization of the [`ptr_meta` RFC][rfc].

[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html

## Usage
# Usage

### Sized types
## 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.
All `Sized` types have `Pointee` implemented for them with a blanket implementation. You do not
need to derive `Pointee` for these types.

### `slice`s and `str`s
## `slice`s and `str`s

These core types have implementations built in.

### Structs with a DST as its last field
# `dyn Any`

The trait object for this standard library type comes with an implementation built in.

You can derive `Pointee` for last-field DSTs:
## Structs with a DST as its last field

You can derive `Pointee` for structs with a trailing DST:

```rust
use ptr_meta::Pointee;
Expand All @@ -30,9 +31,14 @@ struct Block<H, T> {
}
```

### Trait objects
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` for trait objects:
You can generate a `Pointee` implementation for trait objects:

```rust
use ptr_meta::pointee;
Expand Down
2 changes: 1 addition & 1 deletion ptr_meta/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use core::any::Any;
use crate::{DynMetadata, Pointee};
use core::any::Any;

impl Pointee for dyn Any {
type Metadata = DynMetadata<dyn Any>;
Expand Down
Loading

0 comments on commit 61c9ccd

Please sign in to comment.