News for hackers. Stuff that matters.
Re:Cloudflare outage should not have happened by echelon on Wednesday November 26, 2025 @12:41PM (#46060136)
unwrap() and the family of methods like it are a Rust anti-pattern from the early days of Rust. It dates back to before many of the modern error-handling and safety-conscious features of the language and type system.

Rust is being pulled in so many different directions from new users that the language perhaps never originally intended. Some engineers will be fine with panicky behavior, but a lot of others want to be able to statically guarantee most panics (outside of perhaps memory allocation failures) cannot occur.

We need more than just a linter on this. A new language feature that poisons, marks, or annotates methods that can potentially panic (for reasons other than allocation) would be amazing. If you then call a method that can panic, you'll have to mark your own method as potentially panicky. The ideal future would be that in time, as more standard library and 3rd party library code adopts this, we can then statically assert our code cannot possibly panic.

As it stands, I'm pretty mortified that some transitive dependency might use unwrap() deep in its internals.

Re:Cloudflare outage should not have happened by burntsushi on Wednesday November 26, 2025 @06:21PM (#46063441)
> As it stands, I'm pretty mortified that some transitive dependency might use unwrap() deep in its internals.

You'll have to go without std and even the `core` library then.

Re:Cloudflare outage should not have happened by fwip on Wednesday November 26, 2025 @06:28PM (#46063487)
Does #[no_panic] do it for you? https://docs.rs/no-panic/latest/no_panic/
Re:Cloudflare outage should not have happened by Ysraes on Wednesday November 26, 2025 @06:53PM (#46063699)
This is starting to sound a lot like checked exceptions in Java.
Re:Cloudflare outage should not have happened by bigstrat2003 on Thursday November 27, 2025 @12:30AM (#46066007)
Checked exceptions were a great idea which are still, to this day, unfairly maligned.
Re:Cloudflare outage should not have happened by Ysraes on Thursday November 27, 2025 @01:50AM (#46066464)
I don't necessarily disagree, I wasn't making a judgement positively or negatively.
Re:Cloudflare outage should not have happened by asa400 on Wednesday November 26, 2025 @08:06PM (#46064276)
> unwrap() and the family of methods like it are a Rust anti-pattern from the early days of Rust. It dates back to before many of the modern error-handling and safety-conscious features of the language and type system.

I think your argument would be more effective if you dropped this angle.

Unwrap is assert. No more, no less. It's tremendously useful to have it in the language for situations when the cost of encoding some invariant in your program's types is far larger than the benefit you'd gain from doing so. It's not some vestigial thing from way back before anyone received enlightenment that they could use sum types to discriminate errors. It's just a different tool.

I completely agree there are systems and situations where you want to be able to statically verify an absence of panics, but the way you're describing the situation sounds similar to when I hear folks describe anything that came before as "legacy" with a denigrating inflection.