added hash function for ordinal types
This commit is contained in:
parent
60ac5e3e76
commit
414d69ccea
2 changed files with 79 additions and 0 deletions
|
|
@ -115,6 +115,10 @@ proc hash*(x: char): Hash {.inline.} =
|
|||
## efficient hashing of characters
|
||||
result = ord(x)
|
||||
|
||||
proc hash*[T: Ordinal](x: T): THash {.inline.} =
|
||||
## efficient hashing of other ordinal types (e.g. enums)
|
||||
result = ord(x)
|
||||
|
||||
proc hash*(x: string): Hash =
|
||||
## efficient hashing of strings
|
||||
var h: Hash = 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue