As the title says I am having an error in my program and I would like to know how to fix it.
This is the program:
This is the error:
error[E0502]: cannot borrow `doors` as mutable because it is also borrowed as immutable
--> src/main.rs:107:5
|
106 | let open_door = doors.choose(&mut rng).unwrap();
| ---------------------- immutable borrow occurs here
107 | doors.retain(|&x| x != *open_door);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
...
111 | doors_2.retain(|&x| x != sit.choice|open_door);
| --------- immutable borrow later captured here by closure
PS: I do know what is wrong I just don't know the solution