3 ms·
Show me a widely used C library that does even remotely the same thing. I promise you most places where Rust would use unwrap are just straight UB in C. I note
by burntsushi 2y ago
Show me a widely used C library that does even remotely the same thing. I promise you most places where Rust would use unwrap are just straight UB in C.
I note that you provided no real world examples despite my request for them. Where's your code that is following this advice of yours?
- hansvm 2y agoI'm not advocating for C or against Rust though. I'm saying that GP's request to report errors instead of crashing is a perfectly fine opinion, and using Rust as an example of a language which already traps most instances of C UB, there aren't any fundamental reasons why Rust (or a fork or a similar language) couldn't use a different mechanism to signal failure states. Your request for code is irrelevant to my point.
- burntsushi 2y agoYou advocate a particular coding style and I ask for real world examples demonstrating your advocacy in the real world. That's absolutely relevant! In contrast, the style I advocate has dozens of examples at your fingertips running in production right now. Including the Rust standard library itself. The Rust standard library happily uses `unwrap()` all over the place and specifically does not propagate errors that are purely the result of bugs coming from broken internal runtime invariants.