Skip to content

Commit e601b01

Browse files
committed
Implement hashing for custom Some equality
1 parent fea7616 commit e601b01

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

base/some.jl

+1
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,4 @@ macro something(args...)
147147
end
148148

149149
==(a::Some, b::Some) = a.value == b.value
150+
hash(s::Some, h::UInt) = hash(s.value, hash(Some, h))

test/some.jl

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
# Two Somes forward to their wrapped things
5757
@test ==(Some([0x1]), Some([1]))
5858

59+
# hashing implications
60+
@test hash(Some(0x1)) != hash(0x1)
61+
@test hash(Some(0x1)) == hash(Some(1))
62+
5963
@testset "something" begin
6064
@test_throws ArgumentError something()
6165
@test something(1) === 1

0 commit comments

Comments
 (0)