&gt; unless you&#x27;re referring to something like e.g. devirtualization via JIT compilation.<p>Yep.<p>&gt; I was marvelling at how `(0..x).fold(0, |sum, i| sum + i)` (which involves an external iterator, a generic function, and a closure) gets compiled down to the closed-form `((x - 1) * (x - 2) &#x2F; 2) + x - 1`<p>That is very cool, but once iterators are turned into loops (perhaps they&#x27;re even treated specially) and the closure inlined (I would expect both from a decent compiler), it is a rather straightforward optimization (a loop with a constant step). OTOH, a JIT can do this: <a href="https:&#x2F;&#x2F;twitter.com&#x2F;ChrisGSeaton&#x2F;status&#x2F;619885182104043520" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;ChrisGSeaton&#x2F;status&#x2F;619885182104043520</a>