Can't store hashmaps of names in cells; Name could implement Ord
cormacrelf opened this issue · 1 comments
cormacrelf commented
- You can't store a HashMap in a cell, because HashMap does not implement
Hash
. - You could store a
BTreeMap<T>
in a cell, ifT: Ord
, becauseBTreeMap
does implementHash
. Name
does not implementOrd
- So you cannot store a map or set of Names in a cell.
It could, as a basic and very efficient implementation, implement Ord using the precomputed hash value. Then you could put a BTreeMap/BTreeSet in a cell! Edit: no, because Ord has to agree with PartialEq/Eq when Ordering::Equal.
cormacrelf commented
I've thought about this some more and I think if you want sets or maps of cells in your cells e.g. Art<BTreeSet<Art<T>>>
, use a dual of string-based adapton::Name
s + a string interner like https://lib.rs/crates/string-interner, and carry around a wrapper type that implements PartialEq/Eq/PartialOrd/Ord based only on the interned symbol (for that crate, it's a u32).
Then, with Named { symbol: DefaultSymbol, cell: Art<T> }
in hand, use BTreeSet<Named<T>>
.