3 ms·
Not a rust person, but both of the for loop examples seem extremely contrived. If you're going to do .filter , presumably you can do a .map or something and ju
by seanhunter 4y ago
Not a rust person, but both of the for loop examples seem extremely contrived.
If you're going to do .filter , presumably you can do a .map or something and just supply a small lambda which does what was in the body of the for loop in the example?
Alternatively you could just do the filter part using an if statement in the for loop. Either of those syntaxes would be much more straightforward than doing half of one and half of the other. It just doesn't make sense to do that and point at the result as being unergonomic.
Secondly the fact that for and for_each have different characteristics is as someone else has pointed out fundamentally just that blocks and functions are different things. ie it breaks the author's mental model because their mental model is just wrong.