Files
bux-lang/examples/map.bux
T
dimgigov 53b43b0f79 feat: lifetime elision, tooling CI, registry, and LSP locals
Ship the QUALITY_PLAN stretch from ownership through ecosystem: C.1
lifetime elision (bootstrap + selfhost), bux fmt/test/doc CI hooks,
stdlib goldens, package registry (bux search/add), and LSP 0.4
position-sensitive locals with inferred let types. Full-tree format
pass plus Map/Set remove double-free fix.
2026-07-19 16:35:08 +03:00

31 lines
825 B
Plaintext

// Generic Map<K, V> — uses Std::Map (stdlib is merged into module)
import Std::Io::{PrintLine, PrintInt};
import Std::Map::{Map, Map_New, Map_Set, Map_Get, Map_Has, Map_Free};
func Main() -> int {
PrintLine("=== Map<int, String> ===");
let m: Map<int, String> = Map_New<int, String>(16);
Map_Set<int, String>(&m, 1, "one");
Map_Set<int, String>(&m, 2, "two");
Map_Set<int, String>(&m, 3, "three");
PrintLine("Get 1:");
PrintLine(Map_Get<int, String>(&m, 1));
PrintLine("Get 2:");
PrintLine(Map_Get<int, String>(&m, 2));
if Map_Has<int, String>(&m, 1) {
PrintLine("Has 1: yes");
}
// Test update
Map_Set<int, String>(&m, 2, "updated");
PrintLine("Updated 2:");
PrintLine(Map_Get<int, String>(&m, 2));
Map_Free<int, String>(&m);
return 0;
}