Derive Macro DerefMut

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

Derive macro to implement Deref when-ever it’s possible to do automatically.

§Sample :: struct instead of macro.

Write this

#[ derive( DerefMut ) ]
pub struct IsTransparent( bool );

impl ::core::ops::Deref for IsTransparent
{
  type Target = bool;
  #[ inline( always ) ]
  fn deref( &self ) -> &Self::Target
  {
    &self.0
  }
}

Instead of this

pub struct IsTransparent( bool );
impl ::core::ops::Deref for IsTransparent
{
  type Target = bool;
  #[ inline( always ) ]
  fn deref( &self ) -> &Self::Target
  {
    &self.0
  }
}
impl ::core::ops::DerefMut for IsTransparent
{
  #[ inline( always ) ]
  fn deref_mut( &mut self ) -> &mut Self::Target
  {
    &mut self.0
  }
}