-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Option::zip #1475
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
Comments
|
The desired behavior here is to return I think this is a pretty good idea since it's so simple, but I am not sure what the use-case is. |
alternatively there could be an |
Option::zip(a, b) vs (a, b).into() I think that second approach is better, but it type of |
👎 for me. It seems like a niche use case. Also, having an operation named |
FWIW using #243 extended with |
This is now implemented, although unstable. Closing in favor of tracking issue: rust-lang/rust#70086 |
Interesting idea. That’s basically a specialization of applicative functors. Indeed, you use a tuple constructor, but you could do much more with an applicative functor. It’s a pity we don’t have applicative functor notation in Rust. :) As a base of comparison, you do it this way in Haskell: -- all these are identical
x = liftA2 (,) firstMaybe secondMaybe
x = (,) <$> firstMaybe <*> secondMaybe
x = do
a <- firstMaybe
b <- secondMaybe
pure (a, b) |
@phaazon note that we have special-cased let x = try { (first?, second?) }; The |
I sure would like to have the method
Option::zip
Currently I have to do
a.into_iter().zip(b).next()
which is just a tiny bit verbose.The text was updated successfully, but these errors were encountered: