2min chapter

 Rustacean Station  cover image

Rust for Rustaceans by Jon Gjengset

Rustacean Station

CHAPTER

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

Get the Snipd
podcast app

Unlock the knowledge in podcasts with the podcast player of the future.
App store bannerPlay store banner

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode

Save any
moment

Hear something you like? Tap your headphones to save it with AI-generated key takeaways

Share
& Export

Send highlights to Twitter, WhatsApp or export them to Notion, Readwise & more

AI-powered
podcast player

Listen to all your favourite podcasts with AI-powered features

Discover
highlights

Listen to the best highlights from the podcasts you love and dive into the full episode