#[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:
amplify::WrapperMutAsMutcore::borrow::BorrowMutYou may skipAsMutandBorrowMutimplementations with#[wrapper_mut(NoRefs)].
You can implement additional derives, it they are implemented for the
wrapped type, using #[wrapper()] proc macro:
- Reference access to the inner type:
DerefMutfor implementingcore::ops::DerefMutAsSliceMutfor implementingAsMut<[u8]>BorrowSliceMutfor implementingcore::borrow::BorrowMut<[Self::Inner]>
- Indexed access to the inner type:
IndexMutfor implementingcore::ops::IndexMut<usize>IndexRangeMutfor implementingcore::ops::IndexMut<core::ops::Range<usize>>IndexToMutfor implementingcore::ops::IndexMut<core::ops::RangeTo<usize>>IndexFromMutfor implementingcore::ops::IndexMut<core::ops::RangeFrom<usize>>IndexInclusiveMutfor implementingcore::ops::IndexMut<core::ops::RangeInclusive<usize>>IndexToInclusiveMutfor implementingcore::ops::IndexMut<core::ops::RangeToInclusive<usize>>IndexFullMutfor implementingcore::ops::IndexMut<core::ops::RangeFrom<usize>>
- Arithmetic operations:
AddAssignfor implementingcore::ops::AddAssignSubAssignfor implementingcore::ops::SubAssignMulAssignfor implementingcore::ops::MulAssignDivAssignfor implementingcore::ops::DivAssignRemAssignfor implementingcore::ops::RemAssign
- Boolean and bit-wise operations:
BitAndAssignfor implementingcore::ops::BitAndAssignBitOrAssignfor implementingcore::ops::BitOrAssignBitXorAssignfor implementingcore::ops::BitXorAssignShlAssignfor implementingcore::ops::ShlAssignShrAssignfor implementingcore::ops::ShrAssign
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, FromStr)]
#[wrapper_mut(MathAssign, BitAssign)]
struct Int64(i64);