Huh! I was expecting adding u128 integers to be slower because of the cast; but it looks like llvm is (correctly) realising the upcast + downcast has no effect and replacing it with a single u64 add in release mode.
I want to do some additional testing to check if it also optimizes correctly for wasm and in 32 bit contexts, but generally I'm shocked that works so well. Thanks!
I was kinda worried the release case would end up being worse, but it seems okay to me. Does that work for you?
> how do you detect overflow in a debug_assert statement?
compare to usize::MAX cast up to the larger number.