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
Hello,
After a lot of tinkering in my fin/tradefi/crypto space. I appears that the only option now to go directly to own NewType patterns for all things.
One of things we need is correctness and hardness of violate correctness.
This crate is awesome, likely best in space.
But we cannot adopt it as long as it has correctness issue violated.
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: