Skip to content

Commit

Permalink
Implement hashing for custom Some equality
Browse files Browse the repository at this point in the history
  • Loading branch information
Seelengrab committed Dec 6, 2023
1 parent fea7616 commit e601b01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/some.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ macro something(args...)
end

==(a::Some, b::Some) = a.value == b.value
hash(s::Some, h::UInt) = hash(s.value, hash(Some, h))
4 changes: 4 additions & 0 deletions test/some.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
# Two Somes forward to their wrapped things

Check warning on line 56 in test/some.jl

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "Somes" should be "Some or Sums".
@test ==(Some([0x1]), Some([1]))

# hashing implications
@test hash(Some(0x1)) != hash(0x1)
@test hash(Some(0x1)) == hash(Some(1))

@testset "something" begin
@test_throws ArgumentError something()
@test something(1) === 1
Expand Down

0 comments on commit e601b01

Please sign in to comment.