Thanks. Even if I don't use it here, it might help to make code rather fail to compile instead of causing issues at run-time when being ported in future.
I feel like it's reasonable to panic when an integer representing a length information doesn't fit into usize
. Similar to how being out of memory would panic. Hmmmmm, though on the other hand, methods like std::io::Read::take
use u64
for length informations instead of usize
(because you don't need to be able to keep everything in memory). So a length can exceed usize
.
I'll think about it again.
I'll also look at other occurrences of .try_into().unwrap()
in my code. Maybe I use it too carelessly. I started getting used to write .try_into().unwrap()
a lot due to the issues explained in this thread: