Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Align writeas for Dict with wconvert" #498

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading