Skip to content

Commit

Permalink
Add method Ok() = Ok(nothing) (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf authored Apr 24, 2022
1 parent 7d2576a commit 6b2c382
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Try.Ok() = Try.Ok(nothing)
Try.Ok(::Type{T}) where {T} = Try.Ok{Type{T}}(T)

Try.Err(value) = Try.Err(value, maybe_backtrace())
Expand Down
1 change: 1 addition & 0 deletions src/docs/Ok.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Ok(value::T) -> ok::Ok{T}
Ok{T}(value) -> ok::Ok{T}
Ok() -> Ok(nothing)

Indicate that `value` is a "success" in a sense defined by the API returning this value.

Expand Down
1 change: 1 addition & 0 deletions test/TryTests/src/TryTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module TryTests

include("test_core.jl")
include("test_base.jl")
include("test_errortrace.jl")
include("test_tools.jl")
Expand Down
10 changes: 10 additions & 0 deletions test/TryTests/src/test_core.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module TestCore

using Test
using Try

function test_ok_nothing()
@test Ok() === Ok(nothing)::Ok{Nothing}
end

end # module

0 comments on commit 6b2c382

Please sign in to comment.