Re: std.array.array for immutable data types
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
Re: std.array.array for immutable data types
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;
Re: std.array.array for immutable data types
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)); Are you looking for something like assumeUnique [1]? ``` pipe.readEnd.byLineCopy.array.assumeUnique; ``` It's just a nice wrapper for cast(immutable string[]). [1] https://dlang.org/phobos/std_exception.html#assumeUnique