Is it possible to make a recursive closure in Rust?
问题 This is a very simple example, but how would I do something similar to: let fact = |x: u32| { match x { 0 => 1, _ => x * fact(x - 1), } }; I know that this specific example can be easily done with iteration, but I'm wondering if it's possible to make a recursive function in Rust for more complicated things (such as traversing trees) or if I'm required to use my own stack instead. 回答1: There are a few ways to do this. You can put closures into a struct and pass this struct to the closure. You