Targets · Rust · Project setup
Project setup
Everything around the rendered code that makes a working, buildable Cargo crate.
Contents
How a Program becomes Rust, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.
- Introduction — what the Rust target is, and how to read the rest of this section.
- Capabilities — which high-level features are possible, built in or through a crate.
- Example — a full program using every keyword, and the Rust it renders to.
- Naming considerations — how Program's dotted names are carried into Rust.
- Entry point — starting a program from
mainwith its drivers. - Drivers — the native drivers that provide the interface, console and network.
- Runtime — the Reactive and Context machinery the rendered code links against.
- Native modules — the hand-written Rust behind
NATIVEfunctions. - Keywords — how each of Program's keywords renders to Rust.
- Project setup — the files and commands to build and run the rendered program.
- Reserved words — the words Rust keeps for itself, and how a colliding name is escaped.
The files
A rendered Rust program is an ordinary Cargo crate: a Cargo.toml manifest and a
src/ tree, with each top module a mod.
my-app/
Cargo.toml # manifest: name, edition, dependencies
src/
main.rs # fn main() { Program::Application(...) }
reactive/ # the runtime crate (Reactive + Context + drivers)
ui.rs maths.rs ... # one module per top module
# Cargo.toml
[package]
name = "my-app"
edition = "2021"
[dependencies]
reactive = { path = "reactive" }
Build and run
Cargo builds and runs it — no extra tooling.
cargo build # compile
cargo run # build and run
cargo build --release # an optimised binary
The output is a single native binary. The generated code and the runtime are ordinary Rust, so the crate builds and ships exactly like any other.