Functions
A function returns the last expression in its block. Use `return` when an early exit is clearer.
fn add(a: i64, b: i64) {
a + b
}
Syntax
Zust `.zs` files support functions, structs, impls, generics, closures, imports, pattern bindings, expression-oriented control flow, dynamic maps/lists, and direct reassignment.
pub fn demo() {
let p = Point{x: 3.0, y: 4.0};
let scale = |value: f64| {
value * 2.0
};
scale(p.len2())
}
A function returns the last expression in its block. Use `return` when an early exit is clearer.
fn add(a: i64, b: i64) {
a + b
}
Numbers may use explicit suffixes. Strings, tuples, lists, and maps can be used directly in scripts.
let i = 42i32;
let f = 3.14f32;
let pair = (1i32, 2i32);
let object = {name: "Zust", version: 0.9};
`let` supports tuple, list, identifier, wildcard, and typed patterns. Variables, fields, and indexes can be reassigned directly.
`if`/`else` can be used as an expression. `for`, `while`, `loop`, `break`, and `continue` cover ordinary scripting control flow.
struct Point {
x: f64,
y: f64,
}
impl Point {
pub fn len2(self: Point) {
self.x * self.x + self.y * self.y
}
}
Generics express containers, fixed-size arrays, and compile-time precision choices such as `BigFloat<N>`.
Closures can capture outer values and are useful for lightweight transformations and callbacks.
`import("syntax_imported")` defaults to the `.zs` suffix when the path is omitted.