Cannot convert this tail recursive function into an iterative one due to lifetime error #63908
Labels
A-borrow-checker
Area: The borrow checker
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
NLL-polonius
Issues related for using Polonius in the borrow checker
Rust version: 1.37.0
This problem has been previously discussed on Stack Overflow and Rust Users Forum. And I think it is something the Rust compiler can improve on.
I was writing a function that remove the last node from a singly linked list:
Since the recursive call in the function is a tail call, I want to convert the function into an equivalent iterative one:
The function above does not work due to lifetime error:
I think I should be able to convert any valid tail recursive function into an equivalent iterative one without lifetime errors.
The text was updated successfully, but these errors were encountered: