diff options
author | Zahary Karadjov <zahary@gmail.com> | 2018-06-12 23:45:18 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2018-06-16 16:46:32 +0300 |
commit | 5bcf8bcb598d2ca0162f50d2b7250a847026b2c9 (patch) | |
tree | 1c36eda9a58a3347f9fa428e3f4af7dadbe463ee /tests/concepts/libs/trie.nim | |
parent | ea36e0ebbe0033b304a1261de802e2ed9308abf4 (diff) | |
download | Nim-5bcf8bcb598d2ca0162f50d2b7250a847026b2c9.tar.gz |
fixes #7222; fixes #5595; fixes #3747
* late instantiation for the generic procs' default param values * automatic mixin behaviour in concepts Other fixes: * don't render the automatically inserted default params in calls * better rendering of tyFromExpr
Diffstat (limited to 'tests/concepts/libs/trie.nim')
-rw-r--r-- | tests/concepts/libs/trie.nim | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/concepts/libs/trie.nim b/tests/concepts/libs/trie.nim new file mode 100644 index 000000000..bdd318492 --- /dev/null +++ b/tests/concepts/libs/trie.nim @@ -0,0 +1,26 @@ +import + hashes, tables, trie_database + +type + MemDBTable = Table[KeccakHash, string] + + MemDB* = object + tbl: MemDBTable + +proc hash*(key: KeccakHash): int = + hashes.hash(key.data) + +proc get*(db: MemDB, key: KeccakHash): string = + db.tbl[key] + +proc del*(db: var MemDB, key: KeccakHash): bool = + if db.tbl.hasKey(key): + db.tbl.del(key) + return true + else: + return false + +proc put*(db: var MemDB, key: KeccakHash, value: string): bool = + db.tbl[key] = value + return true + |