Skip to content

Commit 68349aa

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 b3b1df9 commit 68349aa

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
@@ -95,24 +95,6 @@ defined order (such as `OrderedDict` and `SortedDict`), and `false` otherwise.
9595
isordered(::Type{T}) where {T<:AbstractDict} = false
9696
isordered(::Type{T}) where {T<:OrderedDict} = true
9797

98-
# conversion between OrderedDict types
99-
function convert(::Type{OrderedDict{K,V}}, d::AbstractDict) where {K,V}
100-
d isa OrderedDict{K, V} && return d
101-
if !isordered(typeof(d))
102-
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)
103-
end
104-
h = OrderedDict{K,V}()
105-
for (k,v) in d
106-
ck = convert(K,k)
107-
if !haskey(h,ck)
108-
h[ck] = convert(V,v)
109-
else
110-
error("key collision during dictionary conversion")
111-
end
112-
end
113-
return h
114-
end
115-
11698
isslotempty(slot_value::Integer) = slot_value == 0
11799
isslotfilled(slot_value::Integer) = slot_value > 0
118100
isslotmissing(slot_value::Integer) = slot_value < 0

0 commit comments

Comments
 (0)