* 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
This commit is contained in:
parent
ea36e0ebbe
commit
5bcf8bcb59
15 changed files with 321 additions and 65 deletions
26
tests/concepts/libs/trie.nim
Normal file
26
tests/concepts/libs/trie.nim
Normal file
|
|
@ -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
|
||||
|
||||
12
tests/concepts/libs/trie_database.nim
Normal file
12
tests/concepts/libs/trie_database.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
type
|
||||
KeccakHash* = object
|
||||
data*: string
|
||||
|
||||
BytesRange* = object
|
||||
bytes*: string
|
||||
|
||||
TrieDatabase* = concept db
|
||||
put(var db, KeccakHash, string) is bool
|
||||
del(var db, KeccakHash) is bool
|
||||
get(db, KeccakHash) is string
|
||||
|
||||
7
tests/concepts/ttrieconcept.nim
Normal file
7
tests/concepts/ttrieconcept.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import libs/[trie_database, trie]
|
||||
|
||||
proc takeDb(d: TrieDatabase) = discard
|
||||
var mdb: MemDB
|
||||
|
||||
takeDb(mdb)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue