hash icon indicating copy to clipboard operation
hash copied to clipboard

ES-22: Provide `OptionExt::ok_or_report` to create reports with a given context for `None`

Open jnicholls opened this issue 3 years ago • 5 comments

I think this would be nice to have vs. ok_or_else() + deliberate Report::new()

jnicholls avatar Jun 17 '22 22:06 jnicholls

Quickly created this issue on my phone, while I was thinking about it. If you accept contributions I’d be happy to contribute this, if you all are amenable to the idea.

jnicholls avatar Jun 17 '22 22:06 jnicholls

Hi @jnicholls! Thanks for the issue, and, yes, we'd love to see contributions!

However, we intentionally did not provide OptionExt to convert Option::None to Report. This decision was made because an Option does not have an error to create a Report from (this is the same reason, why eyre does not provide it).

TimDiekmann avatar Jun 17 '22 22:06 TimDiekmann

@TimDiekmann eyre has an OptionExt::ok_or_eyre So I'd expect something like OptionExt::ok_or_report(IntoReport)

tisonkun avatar Oct 10 '25 15:10 tisonkun

I actually never thought about ok_or_report. A quite low-hanging fruit without unambiguity. Let's just do it!

TimDiekmann avatar Oct 13 '25 08:10 TimDiekmann

Are there any open-source volunteers available? I’m unlikely to be able to work on it in the next 1-2 weeks.

TimDiekmann avatar Oct 14 '25 08:10 TimDiekmann