Loop detection in rust

  1. I am perfectly happy with using Rc instead of GC in 99% of the situations.

  2. I understand that having a tree structured Rc is a "good thing" for understanding the structure of a program.

  3. However, when writing interpreters, it is possible to have situations where loops arise.

  4. Deos Rust have a builtin way where we specify a set of "root" objects, and Rust does a mark & sweep, killing all Rc objects not pointed to by stack or one of the root objects?

No, Rust has no built-in mechanism for this. You probably want to look at GitHub - withoutboats/shifgrethor: garbage collection and/or https://github.com/Manishearth/rust-gc for real GC in Rust.

1 Like