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

Replace map_err() conversions with a From call via the Try operator #239

Merged

Conversation

MarijnS95
Copy link
Contributor

The ? or Try operator in the standard library calls .into() on the Error type before bubbling it up, allowing for natural conversions to other error types. thiserror supports marking such errors as #[from] (implying #[source]) to generate the necessary From<> implementation to facilitate automatic conversion from any specified Error type to the corresponding enum variant in our thiserror enums.

…ator

The `?` or `Try` operator in the standard library calls `.into()` on the
`Error` type before bubbling it up, allowing for natural conversions to
other error types.  `thiserror` supports marking such errors as `#[from]`
(implying `#[source]`) to generate the necessary `From<>` implementation
to facilitate automatic conversion from any specified `Error` type to the
corresponding enum variant in our `thiserror` enums.
@MarijnS95 MarijnS95 force-pushed the use-from-conversion-in-result-try branch from fc6ce2e to 85c70cb Compare November 28, 2023 23:48
@ramosbugs ramosbugs merged commit e24e255 into ramosbugs:main Nov 28, 2023
4 checks passed
@ramosbugs
Copy link
Owner

Thanks!

@MarijnS95 MarijnS95 deleted the use-from-conversion-in-result-try branch November 28, 2023 23:56
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.

2 participants