News for hackers. Stuff that matters.
Re:Rust: A Critical Retrospective by orlp on Thursday May 19, 2022 @07:50PM (#31441712)
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.

There are no comments on this comment yet.