Standard Library
The Rue standard library provides common utilities for Rue programs. It is organized into modules that can be imported using @import("std").
Importing the Standard Library
The standard library is not implicitly imported. You must explicitly import what you need:
const std = @import("std");
const math = std.math;
fn main() -> i32 {
math.abs(-42)
}
Or import specific modules directly:
const math = @import("std").math;
fn main() -> i32 {
math.max(10, 20)
}
Module Structure
The standard library is organized as a module tree:
std/
_std.rue # Module root - re-exports submodules
math.rue # Mathematical utilities
When you write @import("std"), the compiler resolves this to the _std.rue file in the standard library directory. This file re-exports the submodules:
// std/_std.rue
pub const math = @import("math.rue");
Available Modules
| Module | Description |
|---|---|
math | Mathematical functions: abs, min, max, clamp |
Future Modules
As Rue matures, the standard library will grow to include:
- io - Input/output operations
- collections - Data structures like
Vec,HashMap - strings - String manipulation utilities
- mem - Memory utilities
Design Philosophy
The Rue standard library follows several design principles:
- Explicit imports - No implicit prelude; all dependencies are visible
- Lazy analysis - Only imported code is analyzed, enabling fast compilation
- File = module - Each
.ruefile is a module; the filesystem is the source of truth - Simple visibility - Just
pub(public) or nothing (private)
For more details on the module system, see ADR-0026: Module System.