Skip to content

Commit

Permalink
Update for 0.3.0-alpha.3
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Aug 10, 2024
1 parent 512dd59 commit 7ac15e5
Show file tree
Hide file tree
Showing 13 changed files with 501 additions and 323 deletions.
4 changes: 4 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[build]
rustdocflags = ["--cfg", "docsrs"]

[env]
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: rkyv
146 changes: 146 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: "0 10 * * *"

permissions:
contents: read

env:
RUSTFLAGS: -Dwarnings

jobs:
features:
name: Features / ${{ matrix.std }} ${{ matrix.derive }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
std:
- ''
- std
derive:
- ''
- derive

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --verbose --tests --no-default-features --features "${{ matrix.std }} ${{ matrix.derive }}"

toolchain:
name: Toolchain / ${{ matrix.toolchain }} ${{ matrix.opt }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
toolchain:
- stable
- beta
- nightly
opt:
- ''
- --release

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.toolchain }}
- run: cargo test --verbose ${{ matrix.opt }}

miri:
name: Miri / ${{ matrix.opt }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
opt:
- ''
- --release

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri setup
- run: cargo miri test ${{ matrix.opt }} --verbose
env:
MIRIFLAGS: -Zmiri-disable-stacked-borrows -Zmiri-tree-borrows

test:
name: Test / ${{ matrix.target }} ${{ matrix.opt }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
opt:
- ''
- --release
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: aarch64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test ${{ matrix.opt }}

cross:
name: Cross / ${{ matrix.target }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
target:
- i686-unknown-linux-gnu
- i586-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- aarch64-unknown-linux-gnu
- thumbv6m-none-eabi

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cross
- run: cross build --no-default-features --features "derive" --target ${{ matrix.target }} --verbose

format:
name: Format
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --check

clippy:
name: Clippy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo clippy

doc:
name: Doc
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ members = [
resolver = "2"

[workspace.package]
version = "0.3.0-alpha.2"
version = "0.3.0-alpha.3"
authors = ["David Koloski <[email protected]>"]
edition = "2021"
license = "MIT"
documentation = "https://docs.rs/ptr_meta"
repository = "https://github.com/rkyv/ptr_meta"

[workspace.dependencies]
proc-macro2 = "1.0"
ptr_meta_derive = { version = "0.3.0-alpha.2", path = "ptr_meta_derive" }
syn = { version = "2.0", features = ["full"] }
quote = "1.0"
proc-macro2 = { version = "1.0", default-features = false }
ptr_meta_derive = { version = "0.3.0-alpha.2", default-features = false, path = "ptr_meta_derive" }
syn = { version = "2", default-features = false }
quote = { version = "1", default-features = false }
51 changes: 31 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,40 @@ A radioactive stabilization of the [`ptr_meta` RFC][rfc].

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

## Usage
Along with the core [`Pointee`] trait, [`PtrExt`] extension trait, and
helper functions, `ptr_meta` also provides inherent implementations for a
common builtin types:

### Sized types
## Sized types

All `Sized` types have `Pointee` implemented for them with a blanket
implementation. You do not need to derive `Pointee` for these types.
All [`Sized`] types have [`Pointee`] implemented for them with a blanket
implementation. You cannot write or derive [`Pointee`] implementations for
these types.

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

These core types have implementations provided.

### `CStr` and `OsStr`
## `CStr` and `OsStr`

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

### `dyn Any` and `dyn Error`
## `dyn Any` (`+ Send`) (`+ Sync`)

These trait objects have implementations provided.
`dyn Any`, optionally with `+ Send` and/or `+ Sync`, have implementations
provided.

### Structs with a DST as its last field
## `dyn Error` (`+ Send`) (`+ Sync`)

You can derive `Pointee` for structs with a trailing DST:
`dyn Error`, optionally with `+ Send` and/or `+ Sync`, have implementations
provided when the `std` feature is enabled.

```rust
## Structs with trailing DSTs

You can derive [`Pointee`] for structs with trailing DSTs:

```
use ptr_meta::Pointee;
#[derive(Pointee)]
Expand All @@ -43,22 +52,24 @@ struct Block<H, 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.
Note that the last field is required to be a DST. Structs with a generic
type as the last field may have conflicting blanket implementations, as the
generic type may be `Sized`. A collection of specific implementations may be
required in these cases, with the generic parameter set (for example) a
slice, `str`, or specific trait object.

### Trait objects
## Trait objects

You can generate a `Pointee` implementation for trait objects:
You can generate [`Pointee`] implementations for trait objects:

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

Note that this will not produce implementations for `Trait + Send + Sync`.
5 changes: 3 additions & 2 deletions ptr_meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ categories = ["no-std"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ptr_meta_derive.workspace = true
ptr_meta_derive = { workspace = true, optional = true }

[features]
default = ["std"]
default = ["derive", "std"]
derive = ["ptr_meta_derive"]
std = []
64 changes: 0 additions & 64 deletions ptr_meta/README.md

This file was deleted.

3 changes: 2 additions & 1 deletion ptr_meta/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{DynMetadata, Pointee};
use core::any::Any;

use crate::{DynMetadata, Pointee};

// SAFETY: The metadata type of `dyn Any` is `DynMetadata<dyn Any>`.
unsafe impl Pointee for dyn Any {
type Metadata = DynMetadata<dyn Any>;
Expand Down
Loading

0 comments on commit 7ac15e5

Please sign in to comment.