On Thu, Feb 27, 2025 at 3:39 PM Andreas Hindborg <[email protected]> wrote:
>
> +                    // SAFETY: We checked that `val` will fit in `Self` 
> above.
> +                    let val: Self = unsafe { 
> val.try_into().unwrap_unchecked() };

This is wrong -- `val` can be the maximum, and thus it does not fit
since it is 2's complement, even if later the complement would.

In fact, it is caught by the doctest when run with debug assertions enabled:

   /// assert_eq!(Ok(-128), i8::from_str(b_str!("-128")));

We try to put 128 into `i8`, which of course does not work...

Cheers,
Miguel

Reply via email to