failure
failure copied to clipboard
Add a shorthand for Option::ok_or_else with err_msg
I've been thinking of adding a .none_means(msg) (name bikeshed welcome) method to Option which expands .ok_or_else(|| err_msg(msg)). You can use it similar to .expect but returns an error instead of panicking.
I've implemented this in https://github.com/killercup/quicli/pull/25 where you can also find a bit of discussion. If this is something you want to have upstream, i.e., in failure, let me know.
Seems like a useful method. Not really sure if anyone will import an OptionExt trait just for this method though. :-\
Yeah, good point. There's no rush, I'm okay with landing this in quicli itself (once I have a concrete use case) and switching to exporting the upstream version later on.
Am 29.01.2018 um 10:41 schrieb boats [email protected]:
Seems like a useful method. Not really sure if anyone will import an OptionExt trait just for this method though. :-\
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
It makes sense to implement OptionExt (did it the other day, easy) and that the method be called context. Arguably, only saves a few keystrokes but the result looks much clearer.