error task-reuse
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#
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#
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.