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

Add `maybe!` macro equivalent to `try!` #1394

Closed
wants to merge 3 commits into from

Conversation

Projects
None yet
@hauleth
Copy link

hauleth commented Dec 5, 2015

@alexcrichton alexcrichton added the T-libs label Dec 5, 2015

@cassiersg

This comment has been minimized.

Copy link

cassiersg commented Dec 7, 2015

For reference, there also exists a try_opt crate that does the same thing as soma.

@hauleth

This comment has been minimized.

Copy link
Author

hauleth commented Dec 8, 2015

@cassiersg I wasn't aware that this already exist. 👍

@ticki

This comment has been minimized.

Copy link
Contributor

ticki commented Dec 8, 2015

See also #243

@4xrsJCr9

This comment has been minimized.

Copy link

4xrsJCr9 commented Dec 9, 2015

Please consider renaming this macro to 'maybe'.

@hauleth hauleth changed the title Add `try_some` macro equivalent to `try!` Add `maybe!` macro equivalent to `try!` Jan 8, 2016

@reem

This comment has been minimized.

Copy link

reem commented Jan 22, 2016

Some alternatives: Option::and_then or try! with Option::ok_or/Option::ok_or_else depending on what's appropriate.

@aturon aturon added the I-nominated label Feb 2, 2016

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 11, 2016

🔔 This RFC is now entering its week-long final comment period 🔔

The libs team feels that we are likely to not merge this for now in light of trait-based exception handling having recently landed. We're likely to change try! to simply become ? in which case this may mesh more nicely with catch { ... } as proposed there.

@daboross

This comment has been minimized.

Copy link

daboross commented Feb 16, 2016

I feel like this doesn't really need to be a part of the standard library, as it has a lot smaller use case than try! does. I mean it wouldn't be too bad to add it, but it might just be extra bloat.

@skade

This comment has been minimized.

Copy link
Contributor

skade commented Feb 16, 2016

I would strongly avoid naming the macro maybe! for similarity with the type of the same name in other programming languages. Rust uses Option instead of Maybe, maybe! sounds like diverging from that.

@k3d3

This comment has been minimized.

Copy link

k3d3 commented Feb 16, 2016

Having something that deals with Options being called maybe! is confusing IMO - it should be called some!, option!, or opt!.

@nrc

This comment has been minimized.

Copy link
Member

nrc commented Feb 16, 2016

I strongly want a facility for doing this and in the past I've argued for a macro (so many projects have their own for doing this!), however, it seems the best way forward now is to make ? work with Option, so I think we should not accept this RFC (I also don't like maybe as a name, fwiw) and push on getting ? to support Option asap.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Feb 18, 2016

The libs team discussed this RFC during triage yesterday and the conclusion was to close (in the face of trait-based exception handling). Thanks again though for the RFC @hauleth!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.