feat: Hashable instances for UInt8 and UInt16

This commit is contained in:
Leonardo de Moura 2021-10-18 17:19:39 -07:00
parent e336ff5f93
commit c425397b45
2 changed files with 7 additions and 1 deletions

View file

@ -27,6 +27,12 @@ instance [Hashable α] : Hashable (Option α) where
instance [Hashable α] : Hashable (List α) where
hash as := as.foldl (fun r a => mixHash r (hash a)) 7
instance : Hashable UInt8 where
hash n := n.toUInt64
instance : Hashable UInt16 where
hash n := n.toUInt64
instance : Hashable UInt32 where
hash n := n.toUInt64

View file

@ -34,4 +34,4 @@ def tst3 (n : Nat) (expected : UInt32) : IO Unit := do
set_option trace.compiler.ir.result true in
def computeByteHash (bytes : ByteArray) :=
bytes.foldl (init := 1723) fun h b => mixHash h (hash b.toNat)
bytes.foldl (init := 1723) fun h b => mixHash h (hash b)