Skip to content

Types

Scalars, C ABI aliases, views, slices, lists, optionals, unions, and atomics.

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_int, c_long, c_size, c_ssize, c_bool. These are nominal types pinned to the corresponding C ABI widths on the target platform.

Zmeu uses nominal owned types for text and paths rather than overloading slices:

TypeWhat it owns
StringUTF-8 text
ByteBufOwned byte buffer
PathBufFilesystem path (byte-form)
CStringNUL-terminated C string
Path, CStrThe borrowed counterparts of PathBuf and CString

Borrowed text is written view str; borrowed paths/C-strings are view Path and view CStr.

  • 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.

*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.

  • Fixed arrays: [T; N]
  • Borrowed slices: [T] (always behind view or mut 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[:].

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: T | None
  • Union: A | B | C

These are first-class types. Pattern matching narrows them: see Pattern matching.

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)