3 ms·
While I am not versed in Rust, this type of problem has been addressed in other languages with a concept known as Free Monad[0], in which stack space is traded
by AdieuToLogic 1y ago
While I am not versed in Rust, this type of problem has been addressed in other languages with a concept known as Free Monad[0], in which stack space is traded for heap space. While slower, it does eliminate the possibility of stack overflows.
Turns out, there is a Rust crate called higher_free_macro[1] which might fit the bill (to my novice Rust eye).
0 - https://wiki.haskell.org/Free_structure#Free_Monads https://wiki.haskell.org/Free_structure#Free_Monads
1 - https://docs.rs/higher-free-macro/latest/higher_free_macro/ https://docs.rs/higher-free-macro/latest/higher_free_macro/