easy_deref 0.1.0

Derive macros for the `Deref` and `DerefMut` traits
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 20.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 284.29 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • RevlSoftware

easy_deref

Derive macros for the Deref and DerefMut traits that support multi-field structs.

Example

use easy_deref::{Deref, DerefMut};

#[derive(Deref, DerefMut)]
struct Newtype(u32); // Automatically dereferences to `u32`

let nt = Newtype(13);
assert_eq!(*nt, 13);

#[derive(Deref, DerefMut)]
struct<'a, T> ComplexStruct {
    msg: &'a str,
    #[deref] // Dereferences to `data`
    data: Vec<T>,
}

let value = ComplexStruct { msg: "Hello, World!", data: vec![1, 2, 3] };
assert_eq!(*value, vec![1, 2, 3]);

*value = vec![4, 5, 6];
assert_eq!(*value, vec![4, 5, 6]);

License

Licensed under either:

at your option.

Why use easy_deref

With many crates for deriving the Deref and DerefMut traits available, you might be wondering, why use easy_deref? easy_deref is the only crate that allows you to select a field to dereference, allowing support for multi-field structs.