Files
aji/tests/conformance/source/hashset/missing_effect.aji
T
dev 4716cda0f1 cli: add safe owning general-key hash sets
Add std.hashset with explicit pure hash/equality policies and complete
owning keys. Duplicate/full insert returns the original input, while
remove/pop and nonempty free preserve explicit resource ownership.

Reuse safe HashMap storage and failure/peak/refund accounting. Integrate
normative contracts, RFC, references, complexity measurements, CLI/profile
checks and independent Copy/owner set traces.

Validation: 973 conformance cases; runtime set GC and schedule stress;
unit/Quick Reference, formatting, hosted smoke, 53 CLI checks, 106 source
coverage constructs and bundle generation.
2026-10-07 11:14:53 +03:00

24 lines
1.7 KiB
Rust

// expect: reject E3101
// phase: 6
// spec: docs/spec/16-standard-library.md §2.15
module test.hashset
import std.hashset;
import std.option;
fn opened<K, H: fn(ref<K>) -> u64 effects [], E: fn(ref<K>,ref<K>) -> bool effects []>(capacity: usize,heap: cap<mem.alloc>) -> std.hashset.HashSet<K,fn H,fn E> effects [mem.alloc] {
match std.hashset.new::<K,fn H,fn E>(capacity,heap) { std.hashset.NewResult::<K,fn H,fn E>::ok(set) => { return move set; }, std.hashset.NewResult::<K,fn H,fn E>::err(error) => { trap; } }
}
fn inserted<K>(result: std.hashset.InsertResult<K>) -> void effects [] {
match move result { std.hashset.InsertResult::<K>::inserted => {}, std.hashset.InsertResult::<K>::present(key) => { trap; }, std.hashset.InsertResult::<K>::full(key) => { trap; } }
}
fn extracted<K>(result: std.option.Option<K>) -> K effects [] { match move result { std.option.Option::<K>::some(key) => { return move key; }, std.option.Option::<K>::none => { trap; } } }
fn released<K, H: fn(ref<K>) -> u64 effects [], E: fn(ref<K>,ref<K>) -> bool effects []>(set: std.hashset.HashSet<K,fn H,fn E>) -> void effects [] {
match std.hashset.free::<K,fn H,fn E>(move set) { std.hashset.FreeResult::<K,fn H,fn E>::ok => {}, std.hashset.FreeResult::<K,fn H,fn E>::not_empty(set) => { trap; } }
}
struct Key { id: u64, marker: u64 }
fn hash(key: ref<Key>) -> u64 effects [] { return 3; }
fn equal(a: ref<Key>,b: ref<Key>) -> bool effects [] { return a.id == b.id; }
fn bad(q: mut<std.hashset.HashSet<Key,fn hash,fn equal>>,heap: cap<mem.alloc>) -> void effects [] {
match std.hashset.reserve::<Key,fn hash,fn equal>(q,0,heap) { std.hashset.ReserveResult::ok => {}, std.hashset.ReserveResult::err(error) => { trap; } }
}
fn main() -> u64 effects [] { return 42; }