Skip to content

Commit fea7616

Browse files
committed
Define == for Some by forwarding to the wrapped value
1 parent 6a1df3d commit fea7616

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

base/some.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ macro something(args...)
145145
something = GlobalRef(Base, :something)
146146
return :($something($expr))
147147
end
148+
149+
==(a::Some, b::Some) = a.value == b.value

test/some.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@
4949
@test !isequal(Some(1), nothing)
5050
@test !isequal(Some(nothing), nothing)
5151

52+
# Some with something else is false
53+
@test !=(Some(nothing), nothing)
54+
@test !=(nothing, Some(nothing))
55+
56+
# Two Somes forward to their wrapped things
57+
@test ==(Some([0x1]), Some([1]))
58+
5259
@testset "something" begin
5360
@test_throws ArgumentError something()
5461
@test something(1) === 1

0 commit comments

Comments
 (0)