2 ms·
I agree that the snippet you gave is ugly, but I also think that it's not really the most straightforward way to right it. Any time the type that you're collect
by saghm 7y ago
I agree that the snippet you gave is ugly, but I also think that it's not really the most straightforward way to right it. Any time the type that you're collecting into isn't inferred, you're free to define a binding and just type annotate it. Also, the lambda you gave is not defined in the straightforward way I think most people would define it. Putting those together, you get something like this:
```
let vec: Vec<_> = v.iter().map(|pair| pair.0).collect();
```
I don't think that's really _that_ ugly. Yes, the pithy Python example you gave is simpler, but by the same token, the assembly you would write to achieve this makes the Rust look really simple. If you're going to try to write efficient code in a systems language like Rust, you're going to need to express things more precisely than you would in a scripting language like Python.