Modern, flat, zero-cost error flow based on pure struct errors.
⚠️ WARNING: UNAUDITED CODE
This crate was AI-generated and has not undergone human review. It likely contains bugs and should NOT be used in production. The API is subject to change after audit.
struct_error inverts the traditional Rust error model:
- Errors are first-class structs, not enum variants.
- No manual
Ok/Errwrapping inside#[throws]functions. - Pattern match by type name without destructuring nested
Result/Enumlayers. - Zero runtime cost: everything is resolved at compile time via procedural macros.
Core Concepts
| Item | Purpose |
|---|---|
#[error] |
Define an atomic error struct with auto-derived Debug, Display, and Error. |
#[united_error] |
Create a compile-time alias for a set of errors. |
#[throws] |
Rewrite a function to implicitly return Result<T, Unt<...>> and intercept ?. |
match_error! |
Blind, type-driven pattern matching on errors. |
[throw!] |
Explicitly throw an error inside a #[throws] function. |
[Unt] |
Runtime heterogeneous list (nested enum) representing the implicit union. |
[End] |
Uninhabited terminator for the Unt HList. |
Examples
A complete end-to-end example:
use ;
;