Rust-like collect in D

rikki cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 6 07:33:59 PDT 2016


On 07/10/2016 3:32 AM, Nordlöw wrote:
> Is there a concept in D similar to Rust's `collect`:
>
> https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect
>
> If not, I'm eager to implement it to support D-style containers.
>
> What would the desired interface look like?
>
> Perhaps:
>
>     0.iota(n).collect!Array
>
> Or can/should we just overload `std.conv.to` as
>
>     0.iota(n).to!Array
>
> eventhough the element type is not explicit in the expression `to.!Array`?

So an input range to array?
Sure std.array : array.


More information about the Digitalmars-d-learn mailing list