Learn How Rust Converts Recursive Calls into Loops with Tail Call Optimization

Learn how the Rust compiler can optimize some recursive calls into loops with tail call optimization of the recursive call.

The article covers:

  • How Tail Call Optimization (TCO) gets converted into a loop
  • How the Rust compiler can use a hybrid approach with recursion and loops
  • How the compiler optimizes away the enum discriminant when it can infer it from the surrounding context