What is the goal of "never use unwrap"? @Alex Crichton
My thinking is that unwrap()
runs the risk of triggering a panic, and panics in general are bugs we should always be fixing
So in some sense we want to make sure that wasmtime never panics, and if we never use unwrap()
that's one vector of panics we could completely remove
It makes it easy to audit, for example, if unwrap()
is never present, whereas otherwise we have to understand contextually what's happening and consider whether the comment about why the unwrap()
never panics is correct
that's my thinking at least, it's not too advanced nor too strong at all, I don't particularly mind one way or another
I come from a background which is more inclined to worry that by translating "impossible" conditions into runtime errors, you make them more likely to be silently swallowed, when what you really want to do is re-evaluate your assumptions.
But I expect it depends a lot on an assumption that surrounding environments will ultimately be ok with a panic now and then.
nah that's a good point
and silently swallowing errors is arguably worse than getting a bug report for something we should actually fix
Last updated: Nov 22 2024 at 16:03 UTC