I'm looking to implement a finite automaton structure as a set of states, where each state has a HashMap to link it to the other states via reference, s.th. like:

```
pub struct State<T: Eq + Copy + Hash> {
// ...
transitions: HashMap<T, &PfaState<T>>,
}
```

Also, each state has a label, so the overarching structure would be something like:

```
pub struct Automaton<T: Eq + Copy + Hash> {
states: HashMap<Vec<T>, PfaState<T>>,
}
```

Is that even possible without unsafe Rust? I could only think of using unsafe features like this graph implementation: https://github.com/nrc/r4cppp/blob/master/graphs/src/ref_graph.rs, but obviously I'd like to evaluate the safe options first, and it seriously makes my head hurt ... double-borrowing the states map, lifetime issues, the whole protocol ...

Anybody got a hint how to do this safely ?