Skip to content

Change NonZero* TypeInfo implementation to not be recursive#171

Merged
ascjones merged 2 commits intoparitytech:masterfrom
benluelo:v2.2.0/non-zero-type-info-fix
Nov 15, 2022
Merged

Change NonZero* TypeInfo implementation to not be recursive#171
ascjones merged 2 commits intoparitytech:masterfrom
benluelo:v2.2.0/non-zero-type-info-fix

Conversation

@benluelo
Copy link
Copy Markdown
Contributor

@benluelo benluelo commented Nov 14, 2022

The current TypeInfo implementation for the NonZero* types is recursive, defining the types as containing a field of itself. This PR fixes the implementation to properly define the inner field as the NonZero*'s wrapped type.

I also considered if the NonZero* types should be encoded as their wrapped type (i.e. <NonZeroU64 as TypeInfo>::Identity == u64), but I'm not sure what implications that would have.

NOTE: I've forked this off of b881bfb since our current lockfile contains scale-info = 2.2.

Copy link
Copy Markdown
Contributor

@ascjones ascjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

also considered if the NonZero* types should be encoded as their wrapped type (i.e. ::Identity == u64), but I'm not sure what implications that would have.

The Identity associated type is used to uniquely identify a type for registering in the type registry, so it is correct to be Self in this case. If it were e.g. u64 it would collide with that u64 primitive type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants