OxL Справочник OxL
РусскийEnglish

error borrow-conflict

error Стандарт: [§7.2]

Конфликт заимствований.

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#

oxl✓ проверяется в CI
fn main() {
  var xs = [1, 2, 3]
  let first = &xs
  xs.push(4)      // <- borrow-conflict
  print(first.len())
}
error
borrow-conflict

How to fix#

oxl✓ проверяется в CI
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.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства