You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The primitive unsigned integer types only implement Smaller::from(bigger) and Bigger::try_from(smaller). They do not implement Bigger::from(smaller), since that could cause truncation. Instead, as is used to convert without overflow checks and with truncation.
These Uint types should work the same way, to avoid accidentally truncating values. Instead, there should be the following options:
from(...) - only if the conversion is guaranteed to work
try_from(...).unwrap() - similar behavior to new() currently, panic on overflow
from_truncated() - or something like that, for an analogous version of primitive as
(Furthermore, it does not seem to be documented whether the Uint::From implementation truncates or panics on overflow.)
The text was updated successfully, but these errors were encountered:
ariofrio
changed the title
u48::From<u64> should not be implemented, and so on
u48::From<u64> should not be implemented, and so on; missing truncation function (like as)
Sep 23, 2023
The primitive unsigned integer types only implement Smaller::from(bigger) and Bigger::try_from(smaller). They do not implement Bigger::from(smaller), since that could cause truncation. Instead,
as
is used to convert without overflow checks and with truncation.These
Uint
types should work the same way, to avoid accidentally truncating values. Instead, there should be the following options:as
(Furthermore, it does not seem to be documented whether the Uint::From implementation truncates or panics on overflow.)
The text was updated successfully, but these errors were encountered: