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.
11 KiB
API Reference
Generated by bux doc from /// and /* */ documentation comments.
Array
Source: lib/Array.bux
Array struct
struct Array<T> {
Growable contiguous buffer of T (len + capacity).
Array_New func
func Array_New<T>(cap: uint) -> Array<T> {
Create an empty array with the given initial capacity.
Array_Push func
func Array_Push<T>(self: *Array<T>, value: T) {
Append value, growing capacity if needed.
Array_Get func
func Array_Get<T>(self: *Array<T>, index: uint) -> T {
Element at index (bounds-checked unless @[Release]).
Array_Set func
func Array_Set<T>(self: *Array<T>, index: uint, value: T) {
Write value at index (bounds-checked unless @[Release]).
Array_Len func
func Array_Len<T>(self: *Array<T>) -> uint {
Number of live elements.
Array_Free func
func Array_Free<T>(self: *Array<T>) {
Free the backing buffer and reset length/capacity to zero.
Array_Drop func
func Array_Drop<T>(self: *Array<T>) {
Drop trait entry — same as Array_Free.
Array_IsEmpty func
func Array_IsEmpty<T>(self: *Array<T>) -> bool {
True if the array has no elements.
Array_Cap func
func Array_Cap<T>(self: *Array<T>) -> uint {
Current capacity (not length).
Array_Clear func
func Array_Clear<T>(self: *Array<T>) {
Drop length to zero; keeps allocated capacity.
Array_Reserve func
func Array_Reserve<T>(self: *Array<T>, minCap: uint) {
Ensure capacity is at least minCap (does not shrink).
Array_First func
func Array_First<T>(self: *Array<T>) -> T {
First element (bounds-checked if empty).
Array_Last func
func Array_Last<T>(self: *Array<T>) -> T {
Last element (bounds-checked if empty).
Array_Pop func
func Array_Pop<T>(self: *Array<T>) -> T {
Remove and return the last element (bounds-checked if empty).
Array_Contains func
func Array_Contains<T>(self: *Array<T>, value: T) -> bool {
Linear search: true if value is present (uses ==).
Array_IndexOf func
func Array_IndexOf<T>(self: *Array<T>, value: T) -> int {
Index of first equal element, or -1 if not found.
Array_Extend func
func Array_Extend<T>(self: *Array<T>, other: *Array<T>) {
Append all elements of other onto self.
Channel
Source: lib/Channel.bux
Channel_SendInt func
func Channel_SendInt(ch: *Channel<int>, value: int) {
Convenience wrappers for common types
Iter
Source: lib/Iter.bux
Array_Iter func
func Array_Iter<T>(arr: *Array<T>) -> Iter<T> {
Create an iterator from an Array
Iter_HasNext func
func Iter_HasNext<T>(it: *Iter<T>) -> bool {
Check if there are more elements
Iter_Next func
func Iter_Next<T>(it: *Iter<T>) -> T {
Get the next element and advance (undefined if HasNext is false)
Iter_Peek func
func Iter_Peek<T>(it: *Iter<T>) -> T {
Peek current element without advancing (undefined if HasNext is false)
Iter_Reset func
func Iter_Reset<T>(it: *Iter<T>) {
Reset iterator to the beginning
Iter_Pos func
func Iter_Pos<T>(it: *Iter<T>) -> uint {
Current position
Iter_Len func
func Iter_Len<T>(it: *Iter<T>) -> uint {
Remaining length
Iter_Count func
func Iter_Count<T>(it: *Iter<T>) -> uint {
Count remaining elements
Iter_Skip func
func Iter_Skip<T>(it: *Iter<T>, n: uint) {
Skip N elements
Iter_Take func
func Iter_Take<T>(it: *Iter<T>, n: uint) -> Iter<T> {
Take first N elements (by limiting len)
Iter_AnyEq func
func Iter_AnyEq<T>(it: *Iter<T>, value: T) -> bool {
True if any remaining element equals value
Iter_AllEq func
func Iter_AllEq<T>(it: *Iter<T>, value: T) -> bool {
True if every remaining element equals value (true if empty)
Iter_Collect func
func Iter_Collect<T>(it: *Iter<T>) -> Array<T> {
Collect remaining elements into a new Array
Iter_Map func
func Iter_Map<T, U>(it: *Iter<T>, f: func(T) -> U) -> Array<U> {
Map each remaining element through f: T → U, collect into Array
Iter_Filter func
func Iter_Filter<T>(it: *Iter<T>, pred: func(T) -> bool) -> Array<T> {
Keep remaining elements for which pred returns true
Iter_Fold func
func Iter_Fold<T, Acc>(it: *Iter<T>, init: Acc, f: func(Acc, T) -> Acc) -> Acc {
Left-fold: f(f(...f(init, x0), x1), ...)
Iter_ForEach func
func Iter_ForEach<T>(it: *Iter<T>, f: func(T) -> int) {
Call f for each remaining element (return value of f is ignored)
Iter_Any func
func Iter_Any<T>(it: *Iter<T>, pred: func(T) -> bool) -> bool {
True if any remaining element satisfies pred
Iter_All func
func Iter_All<T>(it: *Iter<T>, pred: func(T) -> bool) -> bool {
True if all remaining elements satisfy pred (true if empty)
Iter_SumInt func
func Iter_SumInt(it: *Iter<int>) -> int {
Sum remaining ints (specialized fold)
Json
Source: lib/Json.bux
JsonValue struct
struct JsonValue {
=== Core type ===
Json_Null func
func Json_Null() -> JsonValue {
=== Constructors ===
Json_ArrayLen func
func Json_ArrayLen(v: JsonValue) -> uint {
=== Array helpers ===
Json_ObjectLen func
func Json_ObjectLen(v: JsonValue) -> uint {
=== Object helpers ===
Json_IsNull func
func Json_IsNull(v: JsonValue) -> bool {
=== Accessors ===
JsonParser struct
struct JsonParser {
=== Parser ===
Json_Parse func
func Json_Parse(s: String) -> JsonValue {
=== Public parser ===
Json_StringifyImpl func
func Json_StringifyImpl(sb: *StringBuilder, v: JsonValue) {
=== Serializer ===
Map
Source: lib/Map.bux
Map_Remove func
func Map_Remove<K, V>(m: *Map<K, V>, key: K) -> bool {
Remove key if present. Rebuilds the table to keep open-addressing correct.
Net
Source: lib/Net.bux
Net_Create func
func Net_Create() -> int {
Create a TCP socket. Returns -1 on error.
Net_SetReuse func
func Net_SetReuse(fd: int) -> bool {
Enable SO_REUSEADDR on a socket.
Net_Bind func
func Net_Bind(fd: int, addr: String, port: int) -> bool {
Bind a socket to an address and port.
Net_Listen func
func Net_Listen(fd: int, backlog: int) -> bool {
Start listening for connections.
Net_Accept func
func Net_Accept(fd: int) -> int {
Accept a connection. Returns new fd or -1 on error.
Net_Connect func
func Net_Connect(fd: int, addr: String, port: int) -> bool {
Connect to a remote address and port.
Net_Send func
func Net_Send(fd: int, data: String) -> int {
Send data. Returns bytes sent or -1 on error.
Net_Recv func
func Net_Recv(fd: int, maxLen: int) -> String {
Receive up to maxLen bytes. Returns empty string on error/EOF.
Net_Close func
func Net_Close(fd: int) -> bool {
Close a socket.
Net_LastError func
func Net_LastError() -> String {
Get last socket error as a string.
Option
Source: lib/Option.bux
Option_Expect func
func Option_Expect(o: Option, msg: String) -> int {
Unwrap Some or panic with a custom message
Option_Or func
func Option_Or(o: Option, other: Option) -> Option {
If o is Some return it, otherwise return other
Os
Source: lib/Os.bux
Os_Exit func
func Os_Exit(code: int) {
Terminate the process with the given exit code
Result
Source: lib/Result.bux
Result_Expect func
func Result_Expect(r: Result, msg: String) -> int {
Unwrap Ok or panic with a custom message
Result_UnwrapErr func
func Result_UnwrapErr(r: Result) -> String {
Extract Err payload (panics if Ok)
Result_Or func
func Result_Or(r: Result, other: Result) -> Result {
If r is Ok return it, otherwise return other
Set
Source: lib/Set.bux
Set_Remove func
func Set_Remove<T>(s: *Set<T>, value: T) -> bool {
Remove value if present. Rebuilds the table to keep open-addressing correct.
String
Source: lib/String.bux
String_Len func
func String_Len(s: String) -> uint {
Byte length of a C string (strlen).
String_IsEmpty func
func String_IsEmpty(s: String) -> bool {
True if the string has zero length.
String_IsNull func
func String_IsNull(s: String) -> bool {
True if the pointer is null.
String_Eq func
func String_Eq(a: String, b: String) -> bool {
Lexicographic equality.
String_Concat func
func String_Concat(a: String, b: String) -> String {
Allocate and return a concatenated with b.
String_Copy func
func String_Copy(s: String) -> String {
Heap-copy of s.
String_StartsWith func
func String_StartsWith(s: String, prefix: String) -> bool {
True if s begins with prefix.
String_EndsWith func
func String_EndsWith(s: String, suffix: String) -> bool {
True if s ends with suffix.
String_Contains func
func String_Contains(s: String, substr: String) -> bool {
True if substr occurs anywhere in s.
String_IsBlank func
func String_IsBlank(s: String) -> bool {
True if empty or only whitespace (space, tab, CR, LF).
String_Repeat func
func String_Repeat(s: String, count: uint) -> String {
Repeat s, count times (count == 0 → empty string).
String_ReplaceAll func
func String_ReplaceAll(s: String, old: String, new: String) -> String {
Replace every non-overlapping occurrence of old with new.
Empty old is a no-op (returns s unchanged). Safe if new contains old.
Test
Source: lib/Test.bux
Test_Exit func
func Test_Exit(code: int) {
Exit the process with code (for test runners).
Test_Assert func
func Test_Assert(cond: bool) {
Assert cond is true; abort on failure.
Test_AssertEqInt func
func Test_AssertEqInt(a: int, b: int) {
Assert two ints are equal; print both values and exit 1 on mismatch.
Test_AssertNeqInt func
func Test_AssertNeqInt(a: int, b: int) {
Assert two ints differ.
Test_AssertEqString func
func Test_AssertEqString(a: String, b: String) {
Assert two strings are equal (String_Eq).
Test_AssertEqBool func
func Test_AssertEqBool(a: bool, b: bool) {
Assert two bools are equal.
Test_AssertTrue func
func Test_AssertTrue(cond: bool) {
Assert cond is true.
Test_AssertFalse func
func Test_AssertFalse(cond: bool) {
Assert cond is false.
Test_Fail func
func Test_Fail(msg: String) {
Fail the test with a message and exit 1.
Test_Pass func
func Test_Pass(msg: String) {
Print a PASS line (for human-readable runners / goldens).