(Re)allocating arrays&#x2F;vectors seems to be pretty much the whole point, otherwise both Swift and C++ could not only preallocate (reserve), but they could use iterators and elide all allocation instead, and then you&#x27;d get something along the lines of this:<p><pre><code>    &gt; rustc -O test.rs -o test_rs
    &gt; time .&#x2F;test_rs
    9999010000
            0.54 real         0.53 user         0.00 sys
</code></pre>
here&#x27;s TFA&#x27;s C++ version by comparison:<p><pre><code>    &gt; time .&#x2F;test_cpp
    9999010000
            3.17 real         2.29 user         0.86 sys</code></pre>