Skip to content

Commit

Permalink
Merge d173345 into 4d8facd
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj authored Feb 14, 2021
2 parents 4d8facd + d173345 commit 8523716
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/DataAPI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,18 @@ struct Cols{T<:Tuple}
Cols(args...) = new{typeof(args)}(args)
end

"""
unwrap(x)
For a given scalar argument `x`, potentially "unwrap" it to return the base wrapped value.
Useful as a generic API for wrapper types when the original value is needed.
The default definition just returns `x` itself, i.e. no unwrapping is performned.
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
default definition.
"""
function unwrap end
unwrap(x) = x

end # module
5 changes: 5 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,9 @@ end

end

@testset "unwrap" begin
@test DataAPI.unwrap(1) === 1
@test DataAPI.unwrap(missing) === missing
end

end # @testset "DataAPI"

0 comments on commit 8523716

Please # to comment.