// A region borrow is bound explicitly and outlives the allocation borrows derived from it. // expect: run // grant: heap=mem.alloc:256 // result: 30 // phase: 6 // spec: docs/spec/15-source-language.md module demo.region fn main(heap: cap) -> u64 effects [mem.alloc] { let r = region.create(heap) or trap; var total: u64 = 0; { ref arena = r; match region.new(arena, 10u64) { ok(item) => { *item = *item + 10; total = total + *item; } err(e) => {} } let s = region.array(arena, 4, 2u64) or trap; s[0] = 8; total = total + s[0] + s[1]; } region.reset(r); region.destroy(move r); total }