Async
Asynchronous Stof.
async fn counting_up(now: ms, n: int) -> ms {
for (let i = 0; i < n; i += 1) {}
Time.diff(now)
}
#[main]
fn main() {
const now = Time.now();
const time_to_count = self.counting_up(now, 10_000);
const loop_time = async {
let count = 0;
loop {
count += 1;
if (count >= 10_000) break;
}
Time.diff(now)
};
// can await each promise or a list
pln(await [time_to_count, loop_time]);
}Last updated