Add hashes.hashAllFields

This commit is contained in:
Zahary Karadjov 2021-12-02 20:00:53 +02:00
parent a98ec09b0b
commit 2f9c61f485
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 10 additions and 0 deletions

10
stew/shims/hashes.nim Normal file
View File

@ -0,0 +1,10 @@
import
std/[hashes, typetraits]
func hashAllFields*(x: object|tuple): Hash =
mixin hash
for f in fields(x):
result = result !& hash(f)
result = !$result
export hashes