
Rust for Rustaceans by Jon Gjengset
Rustacean Station
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.
00:00
Transcript
Play full episode
Remember Everything You Learn from Podcasts
Save insights instantly, chat with episodes, and build lasting knowledge - all powered by AI.