Skip to content

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

Merged
ramosbugs merged 2 commits intoramosbugs:mainfrom
Traverse-Research:use-from-conversion-in-result-try
Nov 28, 2023
Merged

Replace map_err() conversions with a From call via the Try operator#239
ramosbugs merged 2 commits intoramosbugs:mainfrom
Traverse-Research:use-from-conversion-in-result-try

Conversation

@MarijnS95
Copy link
Copy Markdown
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
@ramosbugs
Copy link
Copy Markdown
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