3 ms·
I write `for x in some.iter().built().up().like().this()` a lot. I think of the iterator building as mapping values from an iterator to values to consume - the
by sophacles 4y ago
I write `for x in some.iter().built().up().like().this()` a lot.
I think of the iterator building as mapping values from an iterator to values to consume - the for loop consumes them. for_each with side-effects just confuses me later in a lot of those cases - it has it's place but so do for loops. (also, closure issues around variable capture, moves, etc come into play with for_each).
- mustache_kimono 4y agoMostly agree with the points made in your comment, but I think the complaint of the article is "What's the point of having the 'pretty' syntax if it only works in the simplest of cases?" If this is your concern, and you really must write it like that, I'd break it up, into your iter and your loop. let y_iter = some.iter().built().up().like().this(); for x in y_iter { ... }
- tomjakubowski 4y agoyeah you can often come up with a good descriptive name for that y_iter too, like `selected_widgets`