diff --git a/nimutils.nim b/nimutils.nim index da9828e..4e8350a 100644 --- a/nimutils.nim +++ b/nimutils.nim @@ -308,9 +308,9 @@ when isMainModule: print(h2("Dictionary tests")) var - x: DictRef[int, string] = {42: "bar", 1000 : "zork", 17 : "foo", - 500: "boz"}.toDict() - y: Dict[int, string] + x: Dict[int, string] = {42: "bar", 1000 : "zork", 17 : "foo", + 500: "boz"}.toDict() + y: Dict[int, string] = newDict[int, string]() y[500] = "boz" y[1000] = "zork" @@ -336,7 +336,7 @@ when isMainModule: echo y.keys() echo y.values() echo y.items() - var d2: DictRef[string, int] = newDict[string, int]() + var d2: Dict[string, int] = newDict[string, int]() var seqstr = ["ay", "bee", "cee", "dee", "e", "eff", "gee", "h", "i", "j"] for i, item in seqstr: diff --git a/nimutils/crownhash.nim b/nimutils/crownhash.nim index 2464f91..10f05e5 100644 --- a/nimutils/crownhash.nim +++ b/nimutils/crownhash.nim @@ -401,7 +401,8 @@ proc `[]`*[T, V](d: Dict[T, V], key: T) : V = proc toDict*[T, V](pairs: openarray[(T, V)]): Dict[T, V] = ## Use this to convert a nim {} literal to a Dict. - result = Dict[T, V]() + initDict[T, V](result) + for (k, v) in pairs: result[k] = v