Issue with loop and borrowing

I'm helping in adding async support in oxide-auth and facing a borrow checker issue.

To make it async compatible, the maintainer chosed to use state machines that can be driven in a sync or async manner. One was missing and I tried to write.

How come this file compile:

But not mine:

error[E0499]: cannot borrow `authorization` as mutable more than once at a time
   --> oxide-auth\src\code_grant\
330 |         requested = match authorization.advance(input) {
    |                           ^^^^^^^^^^^^^ mutable borrow starts here in previous iteration of loop

both advance() take &mut self and both are used in a loop.

I'm utterly puzzled :cry:

Your requested has lifetime;
enum Requested<'a>


Is that the issue? I put the lifetime because of the stuff I need to pass require one as well.

That was the issue, even if I really don't understand what was going on hereā€¦

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.