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

Consider adding ResultExt::unwrap_report #375

Open
shepmaster opened this issue Apr 1, 2023 · 4 comments
Open

Consider adding ResultExt::unwrap_report #375

shepmaster opened this issue Apr 1, 2023 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@shepmaster
Copy link
Owner

r.unwrap_report();

This would basically boil down to

match r {
    Ok(v) => v,
    Err(e) => panic!("{}", snafu::Report::from_error(e)),
}
@shepmaster shepmaster added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 1, 2023
@shepmaster shepmaster changed the title Consider adding ResultExt unwrap_report Consider adding ResultExt::unwrap_report Apr 1, 2023
@Stargateur
Copy link
Contributor

unwrap_or_report() ? or just report() ?

@Enet4
Copy link
Collaborator

Enet4 commented Apr 2, 2023

I'd favor unwrap_report, which is a pattern already seen in wasm bindgen with unwrap_throw. report would work too, although this one does not convey so well the idea that it may panic. unwrap_or_report would falsely suggest that it creates a report instead of panicking.

@8573
Copy link

8573 commented Apr 2, 2023

unwrap_report sounds like the report is returned in the success (non-divergent) case, as the error is in unwrap_err. Maybe unwrap_reporting, with "reporting" modifying, rather than being an argument to, "unwrap"?

@shepmaster
Copy link
Owner Author

And riffing on that could be reporting_unwrap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants