3 ms·
> 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 mode
by frumplestlatz 11mo ago
> 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.
- burntsushi 11mo agoYou can't model all invariants in the type system. My blog even shows examples of this too.