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: https://github.com/Geobert/oxide-auth/blob/async-authorization/oxide-auth/src/code_grant/resource.rs

But not mine: https://github.com/Geobert/oxide-auth/blob/async-authorization/oxide-auth/src/code_grant/authorization.rs

error[E0499]: cannot borrow `authorization` as mutable more than once at a time
   --> oxide-auth\src\code_grant\authorization.rs:330:27
    |
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>

Thanks!

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.