Custom dictionary type: fieldless keytype, fieldless valtype

Suppose there are some mutable struct types with no fields, and with the default (fallback) equality and hashing methods. A value of such a type has its identity as its only quality. For example:

mutable struct A end
mutable struct B end

Looking for a generic AbstractDict subtype with such fieldless types as keys and values. What’s a good way to implement such a dictionary type, assuming the special properties of the identity-only types may be exploited for achieving better performance.

To be specific, I’m asking for this:

"""
    D{A, B} <: AbstractDict{A, B}

Both `A` and `B` is assumed to be a `mutable struct` type without any field, and with the default, identity-based, equality and default, objectid-based, hashing.
"""
struct D{A, B} <: AbstractDict{A, B}
    # ...
end
# ...

What’s wrong with Dict{A,B}?

Should IdDict just work for this?

Nothing’s wrong with it, I’m just wondering about the most efficient approach.

Possibly. I suppose IdDict is exactly what I’m asking for, on the side of the keys. I still wonder if there’s a better approach when the value type can be assumed to have the stated properties, too. EDIT: scratch that, it seems to be backed by an untyped container, Memory{Any}. That seems like it would limit the performance.