AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
How to Implement a Panic in Rust
Rust has this thing called a panic. They're kind of similar to C++ exceptions in that you can catch them and they are what's known as unwinding exceptions or unwinding panics. In Rust, you can't say like, Oh, you panicked in your comparison operator. Well, you're not allowed to look at the array anymore. You can't do that in Rust. We have to be safe and sound always. It's essentially impossible to write almost any sorting algorithm without unsafe code.