Using #[derive(Sum)] - GitHub Pages
jeltef.github.io › derive_more › derive_moreThe derived Sum implementation will allow an iterator of your type to be summed together into a new instance of the type with all the fields added together. Apart from the original types requiring an implementation of Sum, it is also required that your type to implements Add. So normally you want to derive that one as well.
Using #[derive(Sum)] - GitHub Pages
https://jeltef.github.io/derive_more/derive_more/sum.htmlUsing #[derive(Sum)] 1 Example usage. 2 Structs. 3 Enums. The derived Sum implementation will allow an iterator of your type to be summed together into a new instance of the type with all the fields added together. Apart from the original types requiring an implementation of Sum, it is also required that your type to implements Add.So normally you want to derive that one as well.