error borrow-conflict
What it means#
While an exclusive borrow &var x exists there can be no other borrow and no access to x; while shared borrows &x exist, x cannot be modified (§7.2).
Example#
fn main() {
var xs = [1, 2, 3]
let first = &xs
xs.push(4) // <- borrow-conflict
print(first.len())
}error
borrow-conflict
How to fix#
fn main() {
var xs = [1, 2, 3]
let first = &xs
print(first.len())
xs.push(4)
}End the shared borrow (stop using it) before mutating, or restructure so that the two accesses do not overlap.