// expect: run // result: 42 // grant: heap=mem.alloc:8 // phase: 6 // spec: docs/spec/16-standard-library.md ยง2.10 module test.vec import std.vec; import std.option; fn main(heap: cap) -> u64 effects [mem.alloc] { match std.vec.new::>(0, heap) { std.vec.NewResult::>::ok(value) => { let owner = own.new(42u64, heap) or trap; var answer: u64 = 0; { mut v = value; match std.vec.push::>(v, move owner) { std.vec.PushResult::>::ok => { trap; }, std.vec.PushResult::>::full(returned) => { answer = own.take(move returned); } } } match std.vec.free::>(move value) { std.vec.FreeResult::>::ok => {}, std.vec.FreeResult::>::not_empty(returned) => { trap; } } return answer; } std.vec.NewResult::>::err(e) => { trap; } } }