feat: Hashable instances for UInt8 and UInt16
This commit is contained in:
parent
e336ff5f93
commit
c425397b45
2 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue