Re:&& operator chains (and ||, possibly) generates unoptimiz...
by nicoburns on Monday March 29, 2021 @01:46PM
(#26625526)
You could rewrite this as an iterator, which would avoid this problem and make the code much nicer.
[ Parent
| on HN ]
Re:&& operator chains (and ||, possibly) generates unoptimiz...
by Arnavion on Monday March 29, 2021 @01:48PM
(#26625566)
The hypothetical `foo` is a third-party library function.
(The real code which I reduced to this example is https://github.com/Arnavion/k8s-openapi/blob/1fcfe4b34a1f4f1... , and the callee does happen to be another crate in my control. While this can't be reduced to something like an Iterator, it can be resolved by making the calle take a trait with two `&mut self` methods instead of taking two closures. That still requires changing the callee, of course.)