Derive Macro amplify::WrapperMut

source ·
#[derive(WrapperMut)]
{
    // Attributes available to this derive:
    #[wrap]
    #[wrapper_mut]
    #[amplify_crate]
}
Expand description

Derives WrapperMut and allows deriving other traits accessing the wrapped type which require mutable access to the inner type. Requires that the type already implements amplify::Wrapper.

Supports automatic implementation of the following traits:

You can implement additional derives, it they are implemented for the wrapped type, using #[wrapper()] proc macro:

  1. Reference access to the inner type:
  2. Indexed access to the inner type:
  3. Arithmetic operations:
  4. Boolean and bit-wise operations:

There are shortcuts for derivations:

  • #[wrapper(RangeMut)] will derive all index traits working with ranges (IndexRangeMut, IndexToMut, IndexFromMut, IndexInclusiveMut, IndexToInclusiveMut, IndexFullMut);
  • #[wrapper(MathAssign)] will derive all arithmetic operations (AddAssign, SubAssign, MulAssign, DivAssign, RemAssign);
  • #[wrapper(BoolAssign)] will derive all boolean operations (BitAndAssign, BitOrAssign, BitXorAssign);
  • #[wrapper(BitAssign)] will derive all boolean operations and bit shifts (BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign);

Example

use amplify::{Wrapper, WrapperMut};

#[derive(
    Wrapper, WrapperMut, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, From, Debug,
    Display,
)]
#[display(inner)]
#[wrapper(NumberFmt, MathOps, BoolOps)]
#[wrapper_mut(MathAssign, BitAssign)]
struct Int64(i64);