AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
Wraparounds Cause a Panic in Rust
In rust there is a method on integer types that is specifically wrapping arithmetic like you say wrapping add and that's how you express that i want to do a wrapping ad where don't panic if it overflows. In general an overflow is considered an error same with an underflow and will cause a panic so for example if you implement TCP the sequence numbers for packets wrap around because every sequence number indicates a particular byte offset in the stream. There are cases like if you have no limited size values where overflow is explicitly handled okay yeah your head goes into overdrive.