Files
bux-lang/examples/generic_infer2.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

24 lines
506 B
Plaintext

// Generic function type inference — multiple type parameters
import Std::Io::{PrintLine, PrintInt};
struct Pair<T, U> {
first: T,
second: U,
}
func MakePair<T, U>(a: T, b: U) -> Pair<T, U> {
return Pair<T, U> { first: a, second: b };
}
func Pair_GetFirst<T, U>(self: *Pair<T, U>) -> T {
return self.first;
}
func Main() -> int {
// Inferred: T = int, U = String
let p: Pair<int, String> = MakePair(42, "hello");
PrintInt(p.GetFirst());
PrintLine("");
return 0;
}