From e6f5797b7f890a090eb4584770af31226d5bad78 Mon Sep 17 00:00:00 2001 From: "Zachary P. Christensen" Date: Sun, 25 Sep 2022 02:08:51 -0400 Subject: [PATCH] Doesn't make sense to have reverse for dictionary --- src/PropertyDicts.jl | 9 ++------- test/runtests.jl | 6 ------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/PropertyDicts.jl b/src/PropertyDicts.jl index 1e6a724..fd85445 100644 --- a/src/PropertyDicts.jl +++ b/src/PropertyDicts.jl @@ -2,9 +2,6 @@ module PropertyDicts export PropertyDict -@static if !hasmethod(reverse, Tuple{NamedTuple}) - Base.reverse(nt::NamedTuple) = NamedTuple{reverse(keys(nt))}(reverse(values(nt))) -end @static if !hasmethod(mergewith, Tuple{Any,NamedTuple,NamedTuple}) function Base.mergewith(combine, a::NamedTuple{an}, b::NamedTuple{bn}) where {an, bn} names = Base.merge_names(an, bn) @@ -103,9 +100,9 @@ Base.keytype(@nospecialize T::Type{<:PropertyDict{String}}) = String Base.keytype(@nospecialize T::Type{<:PropertyDict{Symbol}}) = Symbol _tokey(@nospecialize(pd::PropertyDict{String}), k::AbstractString) = k -_tokey(@nospecialize(pd::PropertyDict{String}), k) = String(k) +_tokey(@nospecialize(pd::PropertyDict{String}), k::Symbol) = String(k) _tokey(@nospecialize(pd::PropertyDict{Symbol}), k::Symbol) = k -_tokey(@nospecialize(pd::PropertyDict{Symbol}), k) = Symbol(k) +_tokey(@nospecialize(pd::PropertyDict{Symbol}), k::AbstractString) = Symbol(k) Base.pop!(pd::PropertyDict, k) = pop!(getfield(pd, :d), _tokey(pd, k)) Base.pop!(pd::PropertyDict, k, d) = pop!(getfield(pd, :d), _tokey(pd, k), d) @@ -151,8 +148,6 @@ Base.@propagate_inbounds function Base.setindex!(pd::PropertyDict, v, k) setindex!(getfield(pd, :d), v, _tokey(pd, k)) end -Base.reverse(pd::PropertyDict) = PropertyDict(reverse(getfield(pd, :d))) - @inline function Base.iterate(pd::NamedProperties) if isempty(pd) nothing diff --git a/test/runtests.jl b/test/runtests.jl index 6457567..31671a4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -18,10 +18,6 @@ using Test @test isa(PropertyDict{String,Int}(PropertyDict{String,Int}(Dict("foo" => 1, "bar" => 2))), PropertyDict{String,Int,Dict{String,Int}}) end -# PropertyDict{K,V}(arg, args...) where {K,V} = PropertyDict{K,V}(Dict(arg, args...)) -# PropertyDict{String}(@nospecialize(pd::PropertyDict{String})) = pd - - d = Dict("foo"=>1, :bar=>2) _keys = collect(keys(d)) pd = PropertyDict(d) @@ -109,8 +105,6 @@ end @test Base.IteratorEltype(pd) == Base.IteratorEltype(d) end -@test reverse(PropertyDict((a=1, b=2, c=3))) === PropertyDict(reverse((a=1, b=2, c=3))) - push!(pd, :buz => 10) @test pop!(pd, :buz) == 10 @test pop!(pd, :buz, 20) == 20