4 ms·
Do you mean this one? https://xkcd.com/292/ https://xkcd.com/292/
by Hackbraten 1y ago
Do you mean this one? https://xkcd.com/292/ https://xkcd.com/292/
- 0cf8612b2e1e 1y agoYes, exactly. It is the Rust equivalent of goto.
- vmg12 1y agoGoto is bad because it results in very difficult to reason about code. Using unwrap and expect is as bad as using any other language without null safety.
- int_19h 1y agogoto is bad when it's used in a way that makes it difficult to reason about code, but not all uses of goto are like that. The usual C pattern of `if (err) goto cleanup_resources_and_return_err;` is a good example of the use of goto that is not difficult to reason about. Using unwrap/expect is still much better than using a language without null safety because unwrap/expect make it immediately obvious at which point a panic can occur, and creates some friction for the dev writing the code that makes them less likely to use it literally everywhere.