diff --git a/src/DataAPI.jl b/src/DataAPI.jl index bb5fdc8..8f602ad 100644 --- a/src/DataAPI.jl +++ b/src/DataAPI.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index 0496c7f..b62734c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -85,4 +85,9 @@ end end +@testset "unwrap" begin + @test DataAPI.unwrap(1) === 1 + @test DataAPI.unwrap(missing) === missing +end + end # @testset "DataAPI"