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
There was a bug in the `impl EncodeGaugeValue for u64` implementation
due to the `as i64` cast.
The implementation only checked if `self == u64::MAX`, this is wrong
since `u64::MAX` is not the only value that cannot be represented by an
`i64`.
The range of values is actually `self > i64::MAX`. `u64::MAX == 2^64 -
1` whereas `i64::MAX == 2^63 - 1`, this means there are `2^63` `u64`
values that are not representable by an `i64`, not just `i64::MAX`.
Delegating the checks to `i64::try_from(self)` ensures the logic is
right. For this reason I also switched the rest of the implementations
to use `N::from` instead of `as N` since the `N::from` function is only
implemented for types whose conversion is infallible, this guarantees no
such issues will ever happen.
The only `as` cast left is `u64 as f64` in `EncodeExemplarValue`, this
is not possible to remove since there is no `impl TryFrom<u64> for f64`.
Signed-off-by: Jalil David Salamé Messina <[email protected]>
0 commit comments