Files
bux-lang/lib/Slice.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

40 lines
910 B
Plaintext

module Std::Slice {
extern func bux_bounds_check(index: uint, len: uint);
struct Slice<T> {
data: *T,
len: uint,
}
func Slice_FromArray<T>(arr: *Array<T>) -> Slice<T> {
var s: Slice<T>;
s.data = arr.data;
s.len = arr.len;
return s;
}
func Slice_Get<T>(self: *Slice<T>, idx: uint) -> T {
bux_bounds_check(idx, self.len);
return self.data[idx];
}
func Slice_Set<T>(self: *Slice<T>, idx: uint, value: T) {
bux_bounds_check(idx, self.len);
self.data[idx] = value;
}
func Slice_Len<T>(self: *Slice<T>) -> uint {
return self.len;
}
func Slice_operator_index_get<T>(self: *Slice<T>, idx: uint) -> T {
return Slice_Get<T>(self, idx);
}
func Slice_operator_index_set<T>(self: *Slice<T>, idx: uint, value: T) {
Slice_Set<T>(self, idx, value);
}
}