std.string is a UTF-8 String with the same heap-record shape as std.vec, but operating on byte stride. UTF-8 well-formedness is a documented invariant the producer MUST uphold — the module stores raw bytes and never validates in-band.
Warning
Availability: first shipped with mindc 0.4.0+; as of mindc 0.7.1 the std-surface layer is the shipped default (no opt-in flag).
Layout
String (heap record)
- data_addri64
- leni64
- capi64
data_addr points to slots of 1 byte
- +0
- +1
- +2
- +3
- +4
- …
Struct
i64 fields: data_addr, len, cap.Stride
__mind_load_i64 + mask).Initial capacity
UTF-8
Public API
string_new() -> Stringstring_push_byte(s: String, b: i64) -> Stringstring_push_str(s: String, t: String) -> Stringstring_get(s: String, i: i64) -> i64string_set(s: String, i: i64, b: i64) -> Stringstring_len(s: String) -> i64string_capacity(s: String) -> i64string_free(s: String) -> i64
Example
use std.string;
fn main() -> i64 {
let s = string_new();
let s = string_push_byte(s, 0x48); // 'H'
let s = string_push_byte(s, 0x69); // 'i'
let n = string_len(s); // 2
string_free(s);
return n;
}For real-world I/O, pair std.string with std.io.print_bytes on stdout/stderr.
Forking for stricter invariants (Phase D)
The bundled std.string documents UTF-8 well-formedness as a producer invariant but doesn’t validate inline — a regulated deployment that wants in-band validation can ship its own string.mind and point MIND_STDLIB_PATH=path at it. The project loader swaps the bundled blob at parse time without recompiling mindc. Shipped in v0.4.3 (RFC 0005 Phase D₁); see std.vec for the full override contract.