53b43b0f79
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.
31 lines
541 B
Plaintext
31 lines
541 B
Plaintext
// Generic impl blocks — extend Box<T> with methods
|
|
import Std::Io::{PrintLine, PrintInt};
|
|
|
|
struct Box<T> {
|
|
value: T,
|
|
}
|
|
|
|
extend Box<T> {
|
|
func Get(self: *Box<T>) -> T {
|
|
return self.value;
|
|
}
|
|
|
|
func Set(self: *Box<T>, value: T) {
|
|
self.value = value;
|
|
}
|
|
}
|
|
|
|
func Main() -> int {
|
|
let b: Box<int> = Box<int> { value: 42 };
|
|
PrintLine("Box value:");
|
|
PrintInt(b.Get());
|
|
PrintLine("");
|
|
|
|
b.Set(100);
|
|
PrintLine("Box after Set(100):");
|
|
PrintInt(b.Get());
|
|
PrintLine("");
|
|
|
|
return 0;
|
|
}
|