derived-deref

Crates.ioderived-deref
lib.rsderived-deref
version2.1.0
sourcesrc
created_at2023-07-07 15:52:14.775438
updated_at2023-08-15 21:21:15.101768
descriptionCrate for deriving the `Deref` and `DerefMut` traits
homepage
repositoryhttps://github.com/Sapiet1/derived-deref
max_upload_size
id910896
size20,936
(Sapiet1)

documentation

README

derived-deref

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.

Examples

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);
Commit count: 17

cargo fmt