Rust switches to external iteration

w0rp devw0rp at gmail.com
Thu Jul 4 12:40:23 PDT 2013


On Thursday, 4 July 2013 at 19:26:43 UTC, Jonathan M Davis wrote:
> Sometimes, you're stuck, because the nature of the type that 
> you're dealing
> with forces it to be a pure input range, but you just can't 
> take advantage of
> many algorithms with pure input ranges, which means that you 
> have to write a
> lot more code or use std.array.array in order to use the 
> various algorithms,
> forcing you to allocate when it should be completely 
> unnecessary.

That is exactly why yield is useful, because without yield, you 
have two options.

1. Write a lot of code to create an InputRange. (Cost in time 
taken to write it.)
2. Allocate and lose on performance. (Cost in runtime 
performance.)

Yield gives you option 3.

3. Write very little code while also saving on performance.


More information about the Digitalmars-d mailing list