4 ms·
> But that's basically giving up on informative library-specific error types. It may a valid solution, but it is quite a big leap. Technically the stdlib could
by masklinn 6y ago
> But that's basically giving up on informative library-specific error types. It may a valid solution, but it is quite a big leap.
Technically the stdlib could probably define
Result<T, E=Box<dyn Error>>
That way there wouldn't strictly be any loss, you'd just get a more convenient "application-level" Result OOTB.
I don't know if that would be incompatible with the existing though.
- steveklabnik 6y agoOne serious issue there is that this would no longer be in libcore.
- masklinn 6y agoCouldn't libcore export the current version and std re-export the aliased version with a default? The prelude lives in and uses std, and I don't see people who want exceptions using no_std anyway.
- steveklabnik 6y agoI was thinking no, but I guess you could do something like https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7c19e5e077d082eaf56061675cc4d887 https://play.rust-lang.org/?version=stable&mode=debug&editio...
- masklinn 6y agoYou'd probably need to use the "default type parameter" feature for the alias otherwise std's Result is a breaking change and you have to use core's result to provide a custom error type, which I think would be a step back. It's what anyhow does: pub type Result<T, E = Error> = core::result::Result<T, E>; That way you can still use `Result<i32, MyCustomError>`. I don't know if there are limitations or issues with this approach though.