Best practice when using .unwrap()
in production code is to put a line of documentation immediately above the use of .unwrap()
that describes the safety invariants which allow the unwrap to be safe.
Since code churn could eventually cause those safety invariants to be violated, I think it's not a bad thing for a blunt audit of .unwrap()
to bring your attention to those cases and prompt to reevaluate if the invariants are still satisfied.
You'd be amazed at how resistant most people are to anything that feels unfamiliar, even if it's good for them. Coal and oil jobs are familiar, green jobs are not.
It should be as simple as you're suggesting, but sadly it isn't.