#traits #derived #deref-mut #string #usize #derived-deref #string-wrapper

macro derived-deref

Crate for deriving the Deref and DerefMut traits

5 releases (stable)

2.1.0 Aug 15, 2023
2.0.1 Aug 15, 2023
1.0.0 Jul 7, 2023
0.1.0 Jul 7, 2023

#3 in #derived

Download history 271/week @ 2025-01-28 367/week @ 2025-02-04 239/week @ 2025-02-11 241/week @ 2025-02-18 223/week @ 2025-02-25 379/week @ 2025-03-04 363/week @ 2025-03-11 275/week @ 2025-03-18 338/week @ 2025-03-25 374/week @ 2025-04-01 227/week @ 2025-04-08 400/week @ 2025-04-15 370/week @ 2025-04-22 236/week @ 2025-04-29 278/week @ 2025-05-06 199/week @ 2025-05-13

1,150 downloads per month
Used in 2 crates

MIT/Apache

10KB
112 lines

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);

Dependencies

~175–590KB
~14K SLoC