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

Print location when using expect_throw() #4049

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

daxpedda
Copy link
Collaborator

@daxpedda daxpedda commented Aug 4, 2024

After going over it again I noticed that the UnwrapThrow implementation didn't really make sense. Because if you called expect_throw() you wouldn't get any location information.
So I just manually implemented both unwrap_throw() and expect_throw() for Option and Result and made it as close as possible to Std (apart from the location information).

I also noticed that the implementation I've fixed in #4035 wasn't exactly right, e.g. calling Result::unwrap_throw() would panic instead of throwing without cfg(debug_assertions). Through the overhaul this was fixed as well.

In hindsight, I believe that adding a default implementation on UnwrapThrow was a mistake.

With this I will also close #2732, while leaving the discussion if the whole idea of UnwrapThrow is a good one or not to a different place and time.

Fixes #2732.
Follow-up to #4035 and #4042.

@daxpedda daxpedda merged commit cf186ac into rustwasm:main Aug 4, 2024
27 checks passed
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

Successfully merging this pull request may close these issues.

UnwrapThrowExt should propagate the error for Result<T, E>
1 participant