\$\begingroup\$

I wrote a finite automata implementation in C years ago. C's access to mutable, unsafe, raw pointers made it quite simple for me to link/relink the states of a finite automata.

I read the official Rust Book and wanted to rewrite it in Rust. I ran into problems with recursive references (individual state nodes acting as a linked list). The only thing I could think of is to use Rc<RefCell<State>> - which, as I understand it, are essentially the "unsafe" raw pointers Rust aims to minimize. Am I overthinking it or is this OK Rust code?