Crates.io | derived-deref |
lib.rs | derived-deref |
version | 2.1.0 |
source | src |
created_at | 2023-07-07 15:52:14.775438 |
updated_at | 2023-08-15 21:21:15.101768 |
description | Crate for deriving the `Deref` and `DerefMut` traits |
homepage | |
repository | https://github.com/Sapiet1/derived-deref |
max_upload_size | |
id | 910896 |
size | 20,936 |
A crate for deriving the Deref
and DerefMut
traits from the standard library onto structs with at least one field.
Fields with references are passed directly.
use derived_deref::{Deref, DerefMut};
#[derive(Deref, DerefMut)]
struct StringWithCount {
// Annotation of `#[target]` is required when there are two+ fields.
#[target] inner: String,
count: usize,
}
// When there is only one field, annotation is optional instead.
#[derive(Deref, DerefMut)]
struct StringWrapper(String);
#[derive(Deref, DerefMut)]
struct CountWrapper(#[target] usize);