-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend primitive conversions and implement TryFrom
trait for integer values
#5127
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good otherwise. Just remove all the _u64
and .into_u64()
for the as_b256
functions and then move them into the same impl block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have try_as_uX
methods and some TryFrom
impls? Can we not only use the latter?
These exist prior to the PR in the primitive_conversion.sw file. They will be replaced with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
Description
There have been a number of requests to convert between integer values. This is especially important in some of the recently introduced standards and changes made in the storage optimizations.
This PR extends the primitive conversions to extend values and also implements the
TryFrom
trait foru64
,u32
,u16
, andu8
.Note: The
TryFrom
implementations are not included in the prelude and must be imported. The primitive conversions do not need to be imported as they are included in the core.Checklist
Breaking*
orNew Feature
labels where relevant.