// expect: reject E3002 // phase: 6 // spec: docs/spec/16-standard-library.md ยง2.14 module test.hashmap import std.hashmap; import std.option; fn opened) -> u64 effects [], E: fn(ref, ref) -> bool effects []>(capacity: usize, heap: cap) -> std.hashmap.HashMap effects [mem.alloc] { match std.hashmap.new::(capacity, heap) { std.hashmap.NewResult::::ok(map) => { return move map; } std.hashmap.NewResult::::err(error) => { trap; } } } fn inserted(result: std.hashmap.InsertResult) -> void effects [] { match move result { std.hashmap.InsertResult::::inserted => {}, std.hashmap.InsertResult::::full(value) => { trap; }, std.hashmap.InsertResult::::replaced(value) => { trap; } } } fn extracted(value: std.option.Option) -> T effects [] { match move value { std.option.Option::::some(item) => { return move item; }, std.option.Option::::none => { trap; } } } fn released) -> u64 effects [], E: fn(ref, ref) -> bool effects []>(map: std.hashmap.HashMap) -> void effects [] { match std.hashmap.free::(move map) { std.hashmap.FreeResult::::ok => {}, std.hashmap.FreeResult::::not_empty(value) => { trap; } } } struct Key { id: u64 } fn hash(key: ref) -> u64 effects [] { return 3; } fn equal(a: ref, b: ref) -> bool effects [] { return a.id == b.id; } fn bad(q: mut, fn hash, fn equal>>, key: ref) -> void effects [] { match std.hashmap.remove::, fn hash, fn equal>(q,key) { std.option.Option::>>::some(item) => { return; }, std.option.Option::>>::none => {} } } fn main() -> u64 effects [] { return 42; }