`Weight` function implementations unnecessarily verbose
Several of the Weight implementations are (as the title states) unnecessarily verbose:
not possible, see https://github.com/rust-lang/rust/issues/74935checked_*functions could be made much more succinct by using the?operatorthe
any_*/all_*functions all follow the same pattern:// all_* self.ref_time OP other.ref_time && self.proof_size OP other.proof_size // any_* self.ref_time OP other.ref_time || self.proof_size OP other.proof_sizewhich could very easily be implemented with a
macro_rules!, and would reduce maintenance burden of any fields added in the future.the scalar arithmetic ops have their implementation duplicated, for examplemulhere:https://github.com/paritytech/substrate/blob/master/primitives/weights/src/weight_v2.rs#L274-L276https://github.com/paritytech/substrate/blob/master/primitives/weights/src/weight_v2.rs#L365-L373
unfortunately not possible due to the current trait bounds on
<Weight as Mul<T>>::mul
Also, not possible eitherWeight doesn't impl CheckedMul, which I think it should.
As always, happy to pick this up if it's accepted :slightly_smiling_face:
Source: paritytech/substrate