digitalmars.D.learn - std.array.array for immutable data types
- Fra Mecca (3/3) Feb 18 2018 Is there a way to avoid using to! conversion here?
- Seb (7/10) Feb 18 2018 Are you looking for something like assumeUnique [1]?
- Nicholas Wilson (4/7) Feb 18 2018 assumeUnique.
- Jonathan M Davis (8/16) Feb 19 2018 Arguably, to!(immutable string[]) should work on the result of byLineCop...
Is there a way to avoid using to! conversion here? immutable string[] dst = to!(immutable string[])(array(pipe.readEnd.byLineCopy));
Feb 18 2018
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
Feb 18 2018
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;
Feb 18 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: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 DavisIs 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;
Feb 19 2018