derive_more icon indicating copy to clipboard operation
derive_more copied to clipboard

Attributes for ops macros

Open 50U10FCA7 opened this issue 2 years ago • 1 comments

Proposal

Add a #[add(types(..))] and #[add(forward)] attributes (the same way it works for From and Into) for Add, AddAssign, Sub, SubAssign, Mul and MulAssign macros

It will help to avoid boilerplate for newtype structs.

Example

#[derive(Add, AddAssign, Mul, MulAssign, Sub, SubAssign)]
#[add(types(usize))]
#[mul(forward)]
#[sub(forward)]
pub struct MyIndex(usize);

Edit1: Fixed typo.

50U10FCA7 avatar Feb 24 '23 14:02 50U10FCA7

@50U10FCA7 I guess you've meant #[mul(forward)].

tyranron avatar Feb 24 '23 17:02 tyranron