Skip to content

Commit

Permalink
Revert "Align writeas for Dict with wconvert"
Browse files Browse the repository at this point in the history
  • Loading branch information
sjkelly authored Oct 25, 2023
1 parent 17c6d63 commit 8ad18b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/data/custom_serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# The default, write a type as itself
writeas(T::Type) = T
writeas(::Type{Union{}}, slurp...) = (@assert isempty(slurp); Union{})

# wconvert and rconvert do type conversion before reading and writing,
# respectively. These fall back to convert.
Expand Down Expand Up @@ -66,4 +65,4 @@ function jlconvert(::ReadRepresentation{T,CustomSerialization{S,ODR}},
track_weakref!(f, header_offset, v)
return v
end
end
end
6 changes: 4 additions & 2 deletions src/data/specialcased_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ rconvert(::Type{Core.SimpleVector}, x::Vector{Any}) = Core.svec(x...)

## Dicts

writeas(::Type{<:AbstractDict{K,V}}) where {K,V} = Vector{Pair{K,V}}
writeas(::Type{Dict{K,V}}) where {K,V} = Vector{Pair{K,V}}
writeas(::Type{IdDict{Any,Any}}) = Vector{Pair{Any,Any}}
writeas(::Type{Base.ImmutableDict{K,V}}) where {K,V} = Vector{Pair{K,V}}
wconvert(::Type{Vector{Pair{K,V}}}, x::AbstractDict{K,V}) where {K,V} = collect(x)
function rconvert(::Type{T}, x::Vector{Pair{K,V}}) where {T<:AbstractDict,K,V}
d = T()
Expand Down Expand Up @@ -284,4 +286,4 @@ function writeas(NT::Type{NTuple{N,T}}) where {N,T}
end

wconvert(::Type{Vector{T}}, x::NTuple{N,T}) where {N,T} = collect(x)
rconvert(::Type{NTuple{N,T}}, x::Vector{T}) where {N,T} = NTuple{N,T}(x)
rconvert(::Type{NTuple{N,T}}, x::Vector{T}) where {N,T} = NTuple{N,T}(x)

0 comments on commit 8ad18b8

Please sign in to comment.