Can't convert usize to u64?

But how? Let's see:

  • If foo.into() converted usize to u64:

    • In 64-bit usize — works correctly.
    • In 128-bit usize — does not work correctly, but catches the invalid conversion at compile time.
  • If I have to use foo as u64

    • In 64-bit usize — works correctly.
    • In 128-bit usize — does not work correctly, but the compiler does not catch the invalid conversion. Produces buggy code without warning.

So a 128-bit usize would break this code no matter what. The only difference is that .into() can catch the bug, and as can't.

1 Like