I want to define a HashMap
with a key type of String
and the value type is itself.
I tried to write something like:
HashMap<String, HashMap<String, ...>>
I found this requires recursion and I don't know how to write recursion in a type.
After reading Recursive generic types, I tried:
type HashToHash = HashMap<String, HashToHash>
However I got error:
error[E0391]: cycle detected when processing `HashToHash`
--> src/lib.rs:3:35
|
3 | type HashToHash = HashMap<String, HashToHash>;
| ^^^^^^^^^^
|
= note: ...which again requires processing `HashToHash`, completing the cycle
Is there a way to define this kind of type in Rust?