3 ms·
As a bit of an aside, I get pretty far just rolling errors by hand. Variants fall into two categories, wrappers of an underlying error type, or leafs which are
by nixpulvis 1y ago
As a bit of an aside, I get pretty far just rolling errors by hand. Variants fall into two categories, wrappers of an underlying error type, or leafs which are unique to my application.
For example,
enum ConfigError {
Io(io::Error),
Parse { line: usize, col: usize },
...
}
You could argue it would be better to have a ParserError type and wrap that, and I absolutely might do that too, but they are roughly the same and that's the point. Move the abstraction into their appropriate module as the complexity requests it.
Pretty much any error crate just makes this easier and helps implement quality `Display` and other standard traits for these types.
- echelon 1y ago> I get pretty far just rolling errors by hand And you don't punish your compile times. The macro for everything folks are making Rust slow. If we tire of repetition, I'd honestly prefer checked in code gen. At least we won't repeatedly pay the penalty.
- Expurple 1y ago> At least we won't repeatedly pay the penalty. Another promising solution for that is caching proc macro expansions in the compiler. "How I reduced (incremental) Rust compile times by up to 40%": https://web.archive.org/web/20250311042037/https://www.coderemote.dev/blog/faster-rust-compiler-macro-expansion-caching/ https://web.archive.org/web/20250311042037/https://www.coder...