Skip to content

Commit a7f5ded

Browse files
committed
Allow DataAPI itself to own datavaluetype, nondatavaluetype, and unwrap
1 parent cc2d2de commit a7f5ded

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/DataAPI.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ For a type `T`, return the corresponding non-`DataValue` type, translating betwe
7272
For example, `nondatavaluetype(Int64)` returns `Int64`, while
7373
`nondatavaluetype(DataValue{Int64})` returns `Union{Int64, Missing}`.
7474
75-
This generic function is owned by Tables.jl, which is the sole provider of the default
76-
definition.
75+
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
76+
default definition.
7777
"""
7878
function nondatavaluetype end
7979

80+
nondatavaluetype(::Type{T}) where {T} = T
81+
nondatavaluetype(::Type{Union{}}) = Union{}
82+
8083
"""
8184
datavaluetype(T)
8285
@@ -86,21 +89,26 @@ For a type `T`, return the corresponding `DataValue` type, translating between
8689
For example, `datavaluetype(Int64)` returns `Int64`, while
8790
`datavaluetype(Union{Int64, Missing})` returns `DataValue{Int64}`.
8891
89-
This generic function is owned by Tables.jl, which is the sole provider of the default
90-
definition.
92+
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
93+
default definition.
9194
"""
9295
function datavaluetype end
9396

97+
datavaluetype(::Type{T}) where {T} = T
98+
datavaluetype(::Type{Union{}}) = Union{}
99+
94100
"""
95101
unwrap(x)
96102
97103
For a value `x`, potentially "unwrap" it from a `DataValue` or similar container.
98104
99-
This generic function is owned by Tables.jl, which is the sole provider of the default
100-
definition.
105+
This generic function is owned by DataAPI.jl itself, which is the sole provider of the
106+
default definition.
101107
"""
102108
function unwrap end
103109

110+
unwrap(x) = x
111+
104112
"""
105113
describe(io::IO, x)
106114

0 commit comments

Comments
 (0)