Types
Scalars, C ABI aliases, views, slices, lists, optionals, unions, and atomics.
Scalars
Section titled “Scalars”i32, i64, u8, u32, u64, usize, bool, None.
The unit-style value None is its own type: it appears in Optional shapes and as the return type of procedures.
C ABI aliases
Section titled “C ABI aliases”c_int, c_long, c_size, c_ssize, c_bool. These are nominal types pinned to the corresponding C ABI widths on the target platform.
Owned text and path wrappers
Section titled “Owned text and path wrappers”Zmeu uses nominal owned types for text and paths rather than overloading slices:
| Type | What it owns |
|---|---|
String | UTF-8 text |
ByteBuf | Owned byte buffer |
PathBuf | Filesystem path (byte-form) |
CString | NUL-terminated C string |
Path, CStr | The borrowed counterparts of PathBuf and CString |
Borrowed text is written view str; borrowed paths/C-strings are view Path and view CStr.
Views (borrows)
Section titled “Views (borrows)”view T: shared, non-owning access.mut view T: mutable, non-owning access.
&T and &mut T are legacy compatibility syntax for the same thing; new code should prefer view T / mut view T.
Raw pointers
Section titled “Raw pointers”*const T and *mut T exist for narrow C-extern boundaries only. They are never used in idiomatic Zmeu code outside extern "C": declarations and unsafe: blocks.
Slices and arrays
Section titled “Slices and arrays”- Fixed arrays:
[T; N] - Borrowed slices:
[T](always behindviewormut view) - Indexing:
xs[i] - Slicing:
xs[start:end],xs[:end],xs[start:],xs[:],xs[..]
Mutable slices can be indexed for writes when the borrow + range proof shows the access is valid.
List[T] is the owned, growable container. Element type T must be one of the supported scalar integers, bool, a concrete struct, or a compiler-known owned byte wrapper.
let xs: List[i32] = []xs.push(1)xs.push(2)let total: i32 = xs[0] + xs[1]Other operations: .len, indexing, indexed assignment, .clear(), .truncate(len), and borrowed-slice coercions like view xs[:] / mut view xs[:].
Atomics
Section titled “Atomics”Sequentially consistent atomic types: Atomic[i32], Atomic[u64], Atomic[usize], Atomic[bool].
let counter: Atomic[u64] = Atomic.new_u64(0)let old: u64 = counter.fetch_add(1)Methods: .load(), .store(value), .swap(value), .fetch_add(value), .fetch_sub(value): the last two are restricted to integer element types.
Optional and union
Section titled “Optional and union”- Optional:
T | None - Union:
A | B | C
These are first-class types. Pattern matching narrows them: see Pattern matching.
Nominal generics
Section titled “Nominal generics”Result[T, E], Box[T], and your own generic structs. Generic calls require explicit type arguments at the call site:
let r: Result[i32, bool] = Ok(value=42)let x: i32 = unwrap_or[i32, bool](r, 0)