ocm
The ocm crate provides Outcome<T, E>, an ergonomic type to model operations which can
produce several errors while always returning some value.
This is useful for operations like parsing, where you'd like to gather as many errors as possible before failing.
use ;
// Some operation which always returns a value, but may produce errors while doing so
let outcome = sum_ints;
// `Outcome::finalize` breaks the outcome into:
// - The value
// - An `ErrorSentinel`, which dynamically ensures that errors are handled
let = outcome.finalize;
println!;
if errors.any
Just bundling a value and errors together risks that the errors are accidentally ignored. We'd like to be sure that the errors are handled appropriately.
Unfortunately, Rust lacks the linear type system which would be required to do this statically, so instead it is done at runtime, using panics to signal that errors were dropped without being handled:
use Outcome;
let outcome = new_with_errors;
let = outcome.finalize;
println!;
// Whoops! `errors` was never handled - this will panic.