-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
222 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2021 David Koloski | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ptr_meta   [![Latest Version]][crates.io] [![License]][license path] [![requires: rustc 1.47+]][Rust 1.47] | ||
|
||
[Latest Version]: https://img.shields.io/crates/v/ptr_meta.svg | ||
[crates.io]: https://crates.io/crates/ptr_meta | ||
[License]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license path]: https://github.com/djkoloski/ptr_meta/blob/master/LICENSE | ||
[requires: rustc 1.47+]: https://img.shields.io/badge/rustc-1.47+-lightgray.svg | ||
[Rust 1.47]: https://blog.rust-lang.org/2020/10/08/Rust-1.47.html | ||
|
||
# ptr_meta | ||
|
||
A radioactive stabilization of the [`ptr_meta` RFC][rfc]. | ||
|
||
[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html | ||
|
||
## 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. | ||
|
||
### `slice`s and `str`s | ||
|
||
These core types have implementations built in. | ||
|
||
### Structs with a DST as its last field | ||
|
||
You can derive `Pointee` for last-field DSTs: | ||
|
||
```rust | ||
use ptr_meta::Pointee; | ||
|
||
#[derive(Pointee)] | ||
struct Block<H, T> { | ||
header: H, | ||
elements: [T], | ||
} | ||
``` | ||
|
||
### Trait objects | ||
|
||
You can generate a `Pointee` for trait objects: | ||
|
||
```rust | ||
use ptr_meta::pointee; | ||
|
||
// Generates Pointee for dyn Stringy | ||
#[pointee] | ||
trait Stringy { | ||
fn as_string(&self) -> String; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,13 @@ name = "ptr_meta" | |
version = "0.1.0" | ||
authors = ["David Koloski <[email protected]>"] | ||
edition = "2018" | ||
description = "A radioactive stabilization of the ptr_meta rfc" | ||
license = "MIT" | ||
documentation = "https://docs.rs/ptr_meta" | ||
repository = "https://github.com/djkoloski/ptr_meta" | ||
keywords = ["ptr", "meta", "no_std"] | ||
categories = ["no-std"] | ||
readme = "crates-io.md" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ptr_meta   [![Latest Version]][crates.io] [![License]][license path] [![requires: rustc 1.47+]][Rust 1.47] | ||
|
||
[Latest Version]: https://img.shields.io/crates/v/ptr_meta.svg | ||
[crates.io]: https://crates.io/crates/ptr_meta | ||
[License]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license path]: https://github.com/djkoloski/ptr_meta/blob/master/LICENSE | ||
[requires: rustc 1.47+]: https://img.shields.io/badge/rustc-1.47+-lightgray.svg | ||
[Rust 1.47]: https://blog.rust-lang.org/2020/10/08/Rust-1.47.html | ||
|
||
# ptr_meta | ||
|
||
A radioactive stabilization of the [`ptr_meta` RFC][rfc]. | ||
|
||
[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html | ||
|
||
## 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. | ||
|
||
### `slice`s and `str`s | ||
|
||
These core types have implementations built in. | ||
|
||
### Structs with a DST as its last field | ||
|
||
You can derive `Pointee` for last-field DSTs: | ||
|
||
```rust | ||
use ptr_meta::Pointee; | ||
|
||
#[derive(Pointee)] | ||
struct Block<H, T> { | ||
header: H, | ||
elements: [T], | ||
} | ||
``` | ||
|
||
### Trait objects | ||
|
||
You can generate a `Pointee` for trait objects: | ||
|
||
```rust | ||
use ptr_meta::pointee; | ||
|
||
// Generates Pointee for dyn Stringy | ||
#[pointee] | ||
trait Stringy { | ||
fn as_string(&self) -> String; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# ptr_meta | ||
|
||
A radioactive stabilization of the [`ptr_meta` RFC][rfc]. | ||
|
||
[rfc]: https://rust-lang.github.io/rfcs/2580-ptr-meta.html | ||
|
||
## 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. | ||
|
||
### `slice`s and `str`s | ||
|
||
These core types have implementations built in. | ||
|
||
### Structs with a DST as its last field | ||
|
||
You can derive `Pointee` for last-field DSTs: | ||
|
||
```rust | ||
use ptr_meta::Pointee; | ||
|
||
#[derive(Pointee)] | ||
struct Block<H, T> { | ||
header: H, | ||
elements: [T], | ||
} | ||
``` | ||
|
||
### Trait objects | ||
|
||
You can generate a `Pointee` for trait objects: | ||
|
||
```rust | ||
use ptr_meta::pointee; | ||
|
||
// Generates Pointee for dyn Stringy | ||
#[pointee] | ||
trait Stringy { | ||
fn as_string(&self) -> String; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters