std.array.array for immutable data types

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Feb 19 08:35:38 UTC 2018


On Monday, February 19, 2018 07:25:07 Nicholas Wilson via Digitalmars-d-
learn wrote:
> On Monday, 19 February 2018 at 07:08:49 UTC, Fra Mecca wrote:
> > Is there a way to avoid using to! conversion here?
> >
> > immutable string[] dst = to!(immutable
> > string[])(array(pipe.readEnd.byLineCopy));
>
> assumeUnique.
>
> immutable string[] dst =
> pipe.readEnd.byLineCopy.array.assumeUnique;

Arguably, to!(immutable string[]) should work on the result of byLineCopy,
but it doesn't seem to. If it did, then that would eliminate the need for
assumeUnique, and it's always better to avoid assumeUnique if you can.
However, given the current limitation with to and byLineCopy, it probably is
the best solution.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list