2 ms·
Generally speaking the Left (error) value of a Result is unexpected during normal operation. You "expect" it in that you prepared for a specific kind of failure
by lolinder 3y ago
Generally speaking the Left (error) value of a Result is unexpected during normal operation. You "expect" it in that you prepared for a specific kind of failure but you won't generally see a whole bunch of Left values in a hot loop unless something has gone horribly wrong, in which case performance is not your primary concern.
Meanwhile, one of the biggest weaknesses of Result types is precisely that they don't carry a stack trace with them, which can make it hard to debug a failure when one occurs. Libraries like anyhow in Rust [0] actually go out of their way to retrofit Error types with stack traces because it turns out that most of the time we actually want them.
[0] https://docs.rs/anyhow/latest/anyhow/ https://docs.rs/anyhow/latest/anyhow/