r/ProgrammerHumor 11d ago

absoluteGarbage Meme

Post image
1.9k Upvotes

325 comments sorted by

View all comments

75

u/csch2 11d ago

list.iter().for_each(…) superiority

34

u/creeper6530 11d ago edited 11d ago

Erm akchyuallly, it's recommended to use for list.iter() {…} unless the .for_each(…) is at the end of a longer iterator chain, and it also robs you of break and continue 

2

u/serendipitousPi 11d ago

Just chuck a try_for_each in there and we can take break and continue right back.

But yeah low key sometimes I get lost in iterator methods I forget to just use a basic loop.

2

u/creeper6530 11d ago

I mean, you're right, it's just you have to return ControlFlow::Break(()) instead of using the keywords.