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

> You use `unwrap()` when you know the failure cannot happen.

That’s an invariant meant to be expressed by your type system — and it is.

You’ve failed to model your invariants in your API — and thus the type system — if you ever reach a point where an engineer has to manually assess and assert whether “cannot” applies.

You will get it wrong. That is bad code.



You can't model all invariants in the type system. My blog even shows examples of this too.




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

Search: