added hash function for ordinal types

This commit is contained in:
Fabian Keller
2015-07-03 11:19:17 +02:00
parent 60ac5e3e76
commit 414d69ccea
2 changed files with 79 additions and 0 deletions

View File

@@ -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