The deque holds the string contents, and the set holds views of those contents. This is safe because the deque has iterator stability, and it's pleasant because the `vals` set can just be a regular set.
As you say Rust does not allow this; its answer is IndexSet, and it is implemented differently, like:
RawTable is a hash table that doesn't know how to compute a hash or determine equality. Instead, you provide it with closures to do those tasks, but at the call site (not construction time).
Basically Rust achieves the same thing through a layer of indirection involving indexes, which is a common pattern.
As you say Rust does not allow this; its answer is IndexSet, and it is implemented differently, like:
RawTable is a hash table that doesn't know how to compute a hash or determine equality. Instead, you provide it with closures to do those tasks, but at the call site (not construction time).Basically Rust achieves the same thing through a layer of indirection involving indexes, which is a common pattern.