Thread overview | ||||||
---|---|---|---|---|---|---|
|
July 04, 2022 [Issue 20617] There is no support for copying hashmaps in Druntime / Phobos | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20617 Andrej Mitrovic <andrej.mitrovich@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Component|phobos |druntime --- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> --- Current workaround: ----- import std.array; import std.algorithm; import std.typecons; void main() { int[int] map1 = [1:1, 2:2, 3:3]; int[int] map2 = assocArray(map1.byKeyValue().map!(k => tuple(k.key, k.value))); } ----- Notice that byKeyValue() does not return tuples, instead it returns 'Pair(...)' structs, so these can't directly be passed to `assocArray`. I suppose we could add an overload of `assocArray` that takes in `Pair()`s as arguments, but that seems a bit "leaky" abstractions to me. I'd rather we add an explicit 'duplicate' functionality to Druntime. -- |
July 05, 2022 [Issue 20617] There is no support for copying hashmaps in Druntime / Phobos | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20617 --- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> --- Never mind, I found a better way: ----- import std.array; void main() { int[int] map1 = [1:1, 2:2, 3:3]; int[int] map2 = assocArray(map1.byPair()); } ----- Perhaps this should be added to the docs if it's not already there. -- |
December 17, 2022 [Issue 20617] There is no support for copying hashmaps in Druntime / Phobos | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20617 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P4 -- |
December 07 [Issue 20617] There is no support for copying hashmaps in Druntime / Phobos | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20617 --- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17397 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation