Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Ok-type to () in anyhow::Result typedef #344

Closed
emilk opened this issue Jan 11, 2024 · 2 comments
Closed

Default Ok-type to () in anyhow::Result typedef #344

emilk opened this issue Jan 11, 2024 · 2 comments

Comments

@emilk
Copy link

emilk commented Jan 11, 2024

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
Copy link
Owner

dtolnay commented Jan 11, 2024

I would prefer not to make this change.

You can write your own Result type alias in your crate.

@dtolnay dtolnay closed this as completed Jan 11, 2024
@emilk
Copy link
Author

emilk commented Jan 11, 2024

Fair enough!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants