paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.network/
1.85k stars 668 forks source link

Remove `HasCompact` from `BaseArithmetic` #5004

Open lemunozm opened 3 months ago

lemunozm commented 3 months ago

Hi, for some use cases, it would be appropriate to implement BaseArithmetic for types other than basic Rust number types.

Although all traits from BaseArithmetic are implementable, the HasCompact is not, because it is automatically implemented in parity_scale_codec for T, but it's impossible from an external crate of parity_scale_codec to fulfill the requirements to get the auto implementation of HasCompact for your type.

This basically means that BaseArithmetic is a "sealed" trait where no more types can implement it.

My question is, is HasCompact really a requirement for BaseArithmetic? why do that restriction? If it's not a requirement, can it then be removed from BaseArithmetic?

lemunozm commented 3 months ago

Related issue about implementing HasCompact: https://github.com/paritytech/parity-scale-codec/issues/613