Skip to content

Commit 9d6aed0

Browse files
committed
Remove convert method to OrderedDict
The generic one in Julia stdlib does the job, except for the deprecation warning shown when converting from an unordered dict (such as `Base.Dict`) to an `OrderedDict{K,V}` type. This avoids potential invalidations in packages. There also is no explanation as to why it makes sense to forbids such conversions.
1 parent 8d8c0ed commit 9d6aed0

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

src/ordered_dict.jl

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,6 @@ defined order (such as `OrderedDict` and `SortedDict`), and `false` otherwise.
100100
isordered(::Type{T}) where {T<:AbstractDict} = false
101101
isordered(::Type{T}) where {T<:OrderedDict} = true
102102

103-
# conversion between OrderedDict types
104-
function convert(::Type{OrderedDict{K,V}}, d::AbstractDict) where {K,V}
105-
d isa OrderedDict{K, V} && return d
106-
if !isordered(typeof(d))
107-
Base.depwarn("Conversion to OrderedDict is deprecated for unordered associative containers (in this case, $(typeof(d))). Use an ordered or sorted associative type, such as SortedDict and OrderedDict.", :convert)
108-
end
109-
h = OrderedDict{K,V}()
110-
for (k,v) in d
111-
ck = convert(K,k)
112-
if !haskey(h,ck)
113-
h[ck] = convert(V,v)
114-
else
115-
error("key collision during dictionary conversion")
116-
end
117-
end
118-
return h
119-
end
120-
121103
isslotempty(slot_value::Integer) = slot_value == 0
122104
isslotfilled(slot_value::Integer) = slot_value > 0
123105
isslotmissing(slot_value::Integer) = slot_value < 0

0 commit comments

Comments
 (0)