On Thursday, October 06, 2016 16:56:26 Nordlöw via Digitalmars-d-learn wrote: > On Thursday, 6 October 2016 at 16:14:33 UTC, Dicebot wrote: > > If an entity (i.e. container) implements OutputRange API, you > > can already do it: > > > > 0.iota(n).copy(container); > > Ahh, not quite what I wanted... I want to mimic the functional > style Rust provides, where the `container` is constructed inline > and does not have to be declared separately. Is there a way to do > this, or do we need something similar to `collect` in Phobos? > Something like > > import std.container.array : Array; > > 0.iota(n).collect!Array
That makes it sound like you just need the container to have a constructor that takes a range - either that or a helper function which constructs the container from a range (e.g. std.container.rbTree.redBlackTree is a helper function for constructing a RedBlackTree from a range). - Jonathan M Davis