This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Weight
function implementations unnecessarily verbose #13265
Open
Description
Several of the Weight
implementations are (as the title states) unnecessarily verbose:
-
not possible, see Tracking Issue for the use ofchecked_*
functions could be made much more succinct by using the?
operator?
in constants rust-lang/rust#74935 -
the
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_size
which 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 examplemul
here: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 🙂
Metadata
Metadata
Assignees
Labels
No labels