Open luiswirth opened 4 years ago
I'm not quite sure but I think we just need to store Refcell<Node>
instead of &Node
in the structs to eliminate lifetime problems.
Here are some references or ideas, which might help in solving this problem:
For now we should probably switch to bimap
because we map in both directions.
The current implementation of hasherlife uses
ID
s as handles to the actualNode
s in theHashMap<ID, Node>
. Instead it would be sufficient to use references (&Node
) into aHashSet<Node>
.The largest problem with this refactoring lies in satisfying the borrowck because there are a lot of lifetimes involved. I'm not sure if it is even feasible to do a trivial refactoring or if it's necessary to use different data structures altogether. Maybe there is unsafe code necessary.
Another problem is the immutability of the hashset entries. We need a different way to memoize the computed
Inode::result
because we can't mutate theNode
s.