3 ms·
The sad part is that Rust still has exceptions, they're just called panics. I love Rust to death, but I feel this is a huge flaw in its design. Writing any uns
by orlp 4y ago
The sad part is that Rust still has exceptions, they're just called panics.
I love Rust to death, but I feel this is a huge flaw in its design. Writing any unsafe code that takes a callback function is a massive pain in the ass, because anytime you call this callback, it could panic, so you must restore into a safe state if stack unwinding occurs.
For example, I'm currently writing a fast sorting algorithm, using mostly unsafe code (by necessity). Every time I compare two elements, a panic could occur, and all elements have to be placed back in the input array to restore to a safe state. It's hellish.
There is the panic = abort flag which is great if you're writing a binary. But as a library you can not assume this.