Skip to main content

DerefMut

Derive Macro DerefMut 

Source
#[derive(DerefMut)]
{
    // Attributes available to this derive:
    #[deref_mut]
}
Expand description

Implement DerefMut for a structure.

ยงSample.

use derive_tools::DerefMut;

#[ derive( DerefMut ) ]
struct MyStruct
{
  #[ deref_mut ]
  a: i32,
  b: i32,
}

let mut my_struct = MyStruct { a: 1, b: 2 };
*my_struct += 1;
dbg!( my_struct.a );

To learn more about the feature, study the module derive_tools::DerefMut.