4 ms·
nums.iter().take_while(|x| x <= 10)
by HKH2 5y ago
nums.iter().take_while(|x| x <= 10)
- mamcx 5y agoYeah, I'm aware of the other options, just pointing that the use of lambdas break the flow.
- emi2k01 5y agoRust just standardized `ControlFlow` which would let you pass equivalents of `break` and `continue` as values. x.try_for_each(|y| {...; ControlFlow::Break} )
- mamcx 5y agoYeah, that is cool, and also show the problem :). Internal iterators and/or lambdas are at odds with imperative code. Some guy also yesterday ponder about this stuff: https://www.reddit.com/r/ProgrammingLanguages/comments/pno38l/what_would_a_principled_imperative_language_look/ https://www.reddit.com/r/ProgrammingLanguages/comments/pno38...