-
Notifications
You must be signed in to change notification settings - Fork 138
Enable calling context on Option<T> by adding an OptionExt trait. #277
base: master
Are you sure you want to change the base?
Conversation
I am not sure I like the idea of treating |
Often when Then one would have to be very verbose by:
Here, using
another use case: I have a struct:
where |
Good, I understand your motivation. My question now is if it makes sense to use When I see |
When it comes to https://doc.rust-lang.org/std/path/struct.Path.html#method.to_str , please ask the Rust development team :) When it comes to my usecase, yes, Option is exactly what I need. There is either a session or there is no session. If a user tries to execute an action, which requires an existing session, I need to report a human-readable error. Result is not an option here, since until a call is made, there's no error, so |
I think perhaps the main contention here comes from the fact that you're using the same method name to turn an Perhaps the method should be named |
Ok, I'll change that to |
4dd47e5
to
2d47425
Compare
Is there anything that prevents this from being merged? |
I'm not entirely opposed but also not fully convinced yet that this is a good idea. Does anyone else have opinions on this? |
I'd be very happy with it, I've run into the same verbosity issue many times, and the ability to quickly and conveniently say "This why |
I'm in favor of this change, or something that looks a lot like this. This is something that I've run into often. |
I too think this should exist (in fact i started writing a pull request before seeing it's already here). |
Just adding my experience that yes, this comes up a fair amount in practice when you're calling a function for which The alternative is the slightly verbose |
Is there anything that prevents this change from being merged? |
Since there is no response from the maintainers, I created a crate which provides |
No description provided.