Forgot Expr and got "cannot borrow as mutable more than once" is lifetime elision really the cause?
The Rust Programming Language Forum
Forgot Expr and got "cannot borrow as mutable more than once" is lifetime elision really the cause?
Yesterday I decided to switch my project's Strings over to &str. In the process I forgot to make my parser functions return Expr<'a> instead of plain Expr, and started getting "cannot borrow *self as mutable more than once at a time". I dug into it and also asked an AI about it the explanation I got was that this comes down to lifetime elision: when I don't write Expr<'a> explicitly, the compiler treats it as Expr<'s> instead, tied to the &mut self borrow rather than the struct's own lifetime,...
0 comments
No comments yet.