Default Ok-type to `()` in `anyhow::Result` typedef
Closed this issue · 2 comments
emilk commented
WARNING: This issues is a matter of style and taste! :)
I have a lot of anyhow::Result<()>
in my code base. I find it ugly.
If we change the definition of anyhow::Result
from
pub type Result<T, E = Error> = core::result::Result<T, E>;
to
pub type Result<T = (), E = Error> = core::result::Result<T, E>;
Then we could rewrite
fn foo() -> anyhow::Result<()> {
…
}
to
fn foo() -> anyhow::Result {
…
}
This would NOT be a breaking change (afaict).
dtolnay commented
I would prefer not to make this change.
You can write your own Result type alias in your crate.
emilk commented
Fair enough!