Macro BitAndAssign
macro_rules! BitAndAssign { ... }
What #[derive(AddAssign)] generates
NOTE:
SubAssign,BitAndAssign,BitOrAssignandBitXorAssignderives are fully equivalent to theAddAssignderive described below.
Deriving AddAssign works very similar to deriving Add. The difference is that
it mutates the existing value in-place instead of creating a new one.
Structs
The derived AddAssign implementation will allow two structs of the same type to
be added together, mutating the first one in-place. This is done by AddAssigning
their respective fields.
# use AddAssign;
#
;
This generates code equivalent to:
# use AddAssign;
#
# ;
#
#
#
The behaviour is similar with more or less fields.
Ignoring
Sometimes a struct needs to hold a field (most commonly PhantomData) that doesn't
participate in AddAssign implementation. Such field could be ignored using the
#[add_assign(skip)] attribute.
# use PhantomData;
# use AddAssign;
#
] );
Enums
Deriving AddAssign is not (yet) supported for enums.
This is mostly due to the fact that it is not trivial convert the Add
derivation code, because that returns a Result<EnumType> instead of an EnumType.
Handling the case where it errors would be hard and maybe impossible.