#[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::WrapperMut- [
AsMut] - [
core::borrow::BorrowMut] You 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 implementing [core::ops::DerefMut]AsSliceMutfor implementing [AsMut]<[u8]>BorrowSliceMutfor implementing [core::borrow::BorrowMut]<[Self::Inner]>
- Indexed access to the inner type:
IndexMutfor implementing [core::ops::IndexMut]<usize>IndexRangeMutfor implementing [core::ops::IndexMut]<[core::ops::Range]<usize>>IndexToMutfor implementing [core::ops::IndexMut]<[core::ops::RangeTo]<usize>>IndexFromMutfor implementing [core::ops::IndexMut]<[core::ops::RangeFrom]<usize>>IndexInclusiveMutfor implementing [core::ops::IndexMut]<[core::ops::RangeInclusive]<usize>>IndexToInclusiveMutfor implementing [core::ops::IndexMut]<[core::ops::RangeToInclusive]<usize>>IndexFullMutfor implementing [core::ops::IndexMut]<[core::ops::RangeFrom]<usize>>
- Arithmetic operations:
AddAssignfor implementing [core::ops::AddAssign]SubAssignfor implementing [core::ops::SubAssign]MulAssignfor implementing [core::ops::MulAssign]DivAssignfor implementing [core::ops::DivAssign]RemAssignfor implementing [core::ops::RemAssign]
- Boolean and bit-wise operations:
BitAndAssignfor implementing [core::ops::BitAndAssign]BitOrAssignfor implementing [core::ops::BitOrAssign]BitXorAssignfor implementing [core::ops::BitXorAssign]ShlAssignfor implementing [core::ops::ShlAssign]ShrAssignfor implementing [core::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);