4 ms·
The library ecosystem does fill that gap somewhat with crates like anyhow [1] which also allow you to add context to the errors you return. 1. https://docs.rs/
by jamincan 4y ago
The library ecosystem does fill that gap somewhat with crates like anyhow [1] which also allow you to add context to the errors you return.
1. https://docs.rs/anyhow/latest/anyhow/ https://docs.rs/anyhow/latest/anyhow/
- valenterry 4y agoUnfortunately this does not solve the problem. If you use this, you lose typesafety and the documentation you get through the (inferred) types. I.e. with union types you can see at a glance in your IDE which types of errors a function can return - this is too valuable to give it up.
- zaarn 4y agoYou don't really loose type safety, rather it moves to runtime. Downcasting an anyhow error to the concrete internal type is certainly possible and won't panic in my experience.
- valenterry 4y ago"moves to runtime" exactly means to lose typesafety though.