Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

not surprising though, this is the exact same scenario than with C++ exceptions. if your code is on the happy path, they are consistently faster than error codes


I was wondering whether the Rust compiler could treat Result enums specially and implement them as panics under the hood. But I guess such optimizations are not really feasible because they might change behavior when unwinding through FFI for example. Not even speaking of the possibility that each stack frame is able to convert the error type, unlike exceptions.


It would also change the behavior of panicking destructors on the unwind path, since a second panic during an unwind causes an abort instead of another unwind




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: