diff options
author | Fabian Keller <github.100.fkeller@spamgourmet.com> | 2015-07-03 11:19:17 +0200 |
---|---|---|
committer | Fabian Keller <github.100.fkeller@spamgourmet.com> | 2015-07-03 11:19:17 +0200 |
commit | 414d69ccea7f3ef1a0481a121371e2f0ef7cff80 (patch) | |
tree | 94d28b3188215ba7d104af488b7fac436d88df5e /lib/pure | |
parent | 60ac5e3e76fe24e015782a081da3f04f0000ea5f (diff) | |
download | Nim-414d69ccea7f3ef1a0481a121371e2f0ef7cff80.tar.gz |
added hash function for ordinal types
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/hashes.nim | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/pure/hashes.nim b/lib/pure/hashes.nim index c303c7b4b..fdf0fdb0d 100644 --- a/lib/pure/hashes.nim +++ b/lib/pure/hashes.nim @@ -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 |