Re:The Git source code audit, viewed as a Rust programmer
by stouset on Tuesday January 24, 2023 @12:44PM
(#34507104)
Also what’s fun is that when you have usize and u64, which are both the same size on 64-bit systems, you might instinctively cast between them. But this could truncate the u64 on 32-bit systems, and it could truncate the usize on future 128-bit systems!
So neither type implements From/Into the other, the best you get are TryFrom/TryInto where you either have to handle an error or discard it after “proving” overflow can’t happen.
This is unambiguously the correct behavior, but it is sort of frustrating at times.
So neither type implements From/Into the other, the best you get are TryFrom/TryInto where you either have to handle an error or discard it after “proving” overflow can’t happen.
This is unambiguously the correct behavior, but it is sort of frustrating at times.