error[E0499]: cannot borrow `*self` as mutable more than once at a time
--> src/plot.rs:216:17
|
216 | self.round_seek_addr(&mut self.com.know_scope_current_offset);
| ^^^^^---------------^---------------------------------------^
| | | |
| | | first mutable borrow occurs here
| | first borrow later used by call
| second mutable borrow occurs here
error[E0499]: cannot borrow `self.com.know_scope_current_offset` as mutable more than once at a time
--> src/plot.rs:216:38
|
216 | self.round_seek_addr(&mut self.com.know_scope_current_offset);
| ---- --------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | |
| | first borrow later used by call
| first mutable borrow occurs here
error[E0499]: cannot borrow `*self` as mutable more than once at a time
--> src/plot.rs:218:17
|
218 | self.round_seek_addr(&mut self.com.unknow_scope_current_offset);
| ^^^^^---------------^-----------------------------------------^
| | | |
| | | first mutable borrow occurs here
| | first borrow later used by call
| second mutable borrow occurs here
error[E0499]: cannot borrow `self.com.unknow_scope_current_offset` as mutable more than once at a time
--> src/plot.rs:218:38
|
218 | self.round_seek_addr(&mut self.com.unknow_scope_current_offset);
| ---- --------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ second mutable borrow occurs here
| | |
| | first borrow later used by call
| first mutable borrow occurs here
error[E0499]: cannot borrow `*self` as mutable more than once at a time
--> src/plot.rs:219:47
|
219 | self.com.final_hash_current_len = self.round_seek_addr(&mut self.com.final_hash_offset);
| ^^^^^---------------^-------------------------------^
| | | |
| | | first mutable borrow occurs here
| | first borrow later used by call
| second mutable borrow occurs here
In this case, the &mut self and &mut self.com.know_scope_current_offset references overlap, but mutable references are not allowed to overlap with any other reference in the program. Thus it does not compile.
Maybe round_seek_addr should not be a method on self?
fn round_seek_addr(sector_size: usize, seek_addr: &mut u64) -> u64 {
let r = *seek_addr % sector_size;
if r != 0 {
let offset = sector_size - r;
*seek_addr += offset;
offset
} else {
0
}
}