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

Extend Option with ok_or_eyre #129

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

LeoniePhiline
Copy link
Contributor

Previously, a closure and macro invocation was
required to generate a static string error object
from an Option::None.

This change adds an extension trait, providing
the ok_or_eyre method on the Option type.

Option::ok_or_eyre accepts static error messages
and creates Report objects lazily in the None case.

Implements #125

@LeoniePhiline LeoniePhiline force-pushed the feat/option-ext branch 4 times, most recently from b88e132 to 5e73f0f Compare December 6, 2023 15:23
Copy link
Contributor

@ten3roberts ten3roberts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing improvement.

This will reduce the friction so much, as a embarrassingly large usage of my eyre macro is hydrating None failures, and I suspect that it may be the case for many others ❤️

@LeoniePhiline LeoniePhiline force-pushed the feat/option-ext branch 2 times, most recently from 49d4d96 to f1c5ab7 Compare December 6, 2023 16:11
Previously, a closure and macro invocation was
required to generate a static string error object
from an `Option::None`.

This change adds an extension trait, providing the
`ok_or_eyre` method on the `Option` type.

`Option::ok_or_eyre` accepts static error messages
and creates `Report` objects lazily in the `None`
case.

Implements eyre-rs#125
@ten3roberts
Copy link
Contributor

I will merge this now as it looks splendid. If you find a better way to make it discoverable; feel free to open up another PR 😊

@ten3roberts ten3roberts merged commit 4e1f323 into eyre-rs:master Dec 6, 2023
29 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.

None yet

2 participants