-
Notifications
You must be signed in to change notification settings - Fork 310
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 conversion into (Option<A>,Option<B>) to EitherOrBoth #713
Conversation
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
I was literally about to cut an issue for this! I've been using this library for a little while, but every time I use zip_longest I seem to bump up against the problem where I can't just operate on left if it exists and right if it exists. If not an explicit conversion, at least an "either()" function that would convert it to this type just like it has |
Maybe have it be an |
I am open to all options, I just think a Into trait may be more generic, I for example like to sometimes write something like fn some_fn<A,B>(param_a: impl Into<(Option<A>,Option<B>)>) -> ... and a into impl would then allow to accept EitherOrBoth as well as other structs that implement the corresponding Into trait. Maybe that's just me tho. Would be open to add a method as well or switch it to a method only, If anyone has good points for either option feel free to add them :) I can't make the final decision tho, I am not a maintainer here. |
Hmm, is there anything else that's I understand |
What about |
I mean having both and then rust delegating the into impl to the method (maybe with #[inline(always)]) wouldn't hurt either, right? |
I'll just add the method for now, I think |
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
Hi there, thanks a lot for this. Please remove the And please use @Philippe-Cholet 's implementation: Side note: I guess we'd ideally want to be able to write something like |
Re the side note: You're thinking that in terms of needing a generic closure, so that |
Exactly. Admittedly, Rust allows me to define this:
But the above function cannot be called (at least I did not find any straightforward way). (In stable Rust.) |
@phimuemue I suppose we could go with Then, looking at
|
Signed-off-by: Justus Fluegel <justusfluegel@gmail.com>
I think that should satisfy both requests, sorry that I haven't responded in a while, had to study for one of my exams ( Uni ) and wasn't online during that time. |
I don't know if that would be a good idea but we could theoretically change the
Edit no 2 nevermind that wouldn't work |
Thank you. Hope your exam went well. bors r+ |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Hey!
I recently found a conversion into
(Option<A>,Option<B>)
quite useful. Just wondered if there was any interest adding this directly to upstream here. If not, just close this pr :)Thanks