v0.13: Async, WebSockets, Debugger & Devlogv0.13.0
Native async/await, First-Class Closures & Constrained Generics
Parallel Task<T> execution, fn(A): R closures with read-only capture, and where/nerede interface constraints on generic free functions.
6 min readUpdated: v0.13.0 Reference
Parallel async / await & Task<T>
HADID v0.13.0 runs async fn tasks on a bounded OS worker pool with isolated per-task arenas:
hadid
async fn fetch_score(id: i32): Result<i32, string> {
sleep_ms(10);
return Ok(id * 100);
}
async fn run(): Result<i32, string> {
let t1 = fetch_score(1);
let t2 = fetch_score(2);
return Ok((await t1?) + (await t2?));
}Use await_all(tasks) to collect a List<Task<T>> into List<T>.
First-Class Closures & Constrained Generics
hadid
fn apply_twice(x: i32, f: fn(i32): i32): i32 { return f(f(x)); }
interface ISummarizable { fn summary(): string; }
fn format_item<T>(item: T): string where T : ISummarizable {
return $"[ITEM] {item.summary()}";
}