The standard Rust approach defines large error enums per module or crate, causing functions to return enums with unreachable variants.
Rust’s type system could enforce error requirements more precisely, but creating separate error enums for every function is tedious.
The terrors crate treats errors as independent structs and broadens error sets via map_err for modular error handling.
The error_set crate uses macros to concisely define error sets and automatically generate trait implementations for error conversions.
The error_set macro enables the `?` operator when the function’s error set is a superset of the invoked function’s errors.
Other libraries like SmartErr and attribute macros explore automated error enum generation based on function bodies.
Get notified when new stories are published for "🇺🇸 Hacker News English"