How to handle pin and mutable

error[E0502]: cannot borrow `self` as immutable because it is also borrowed as mutable
  --> src/future/prio_retry.rs:96:54
   |
89 |                     if let Some(ref mut delayed_item) = self.delayed_item {
   |                                                         ---- mutable borrow occurs here
...
96 |                             delayed_item.exp_backoff(self.delay_duration);
   |                                          ----------- ^^^^ immutable borrow occurs here
   |                                          |
   |                                          mutable borrow later used by call

Since Duration is Copy, you can just do

let delay_duration = self.delay_duration;
if let Some(ref mut delayed_item) = self.delayed_item {
    ...
    delayed_item.exp_backoff(delay_duration);
}

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.