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

error task-reuse

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

Task одноразовый и уже был использован.

What it means#

A Task is movable and single-use: exactly one operation consumes it (await, spawn, a combinator or starting a chain) (§8.3). Awaiting or spawning the same task a second time is a use of a moved value.

Example#

oxl✓ проверяется в CI
fn compute() -> i32 => 1

fn main() io, time {
  let t = Task.of { compute() }
  let a = await t
  let b = await t      // <- task-reuse
  print("{a} {b}")
}
error
task-reuse

How to fix#

oxl✓ проверяется в CI
fn compute() -> i32 => 1

fn main() io, time {
  let a = await Task.of { compute() }
  let b = await Task.of { compute() }
  print("{a} {b}")
}

Create a fresh task for every run, or keep the result of the first await and reuse that value.

See also#

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