Rust

Learn Rust by extending the concrete process, memory, file, and concurrency model you already built. Each chapter adds one ownership or type relationship, produces exact evidence, and names the stronger claim that still remains unproved.

Course details and reading size
Tutorial
Reading comfortAdjust lesson text without changing code or interface size.

Your first Rust 2021 program: source, compiler, value, and output

Objective Save one complete Rust source file, compile it under strict diagnostics, run one executable, and compare exact evidence.

Core explanation

A Rust source file is plain text. In this chapter, rustc reads hello.rs under the Rust 2021 edition and either reports a diagnostic or creates one local executable. The program owns one u8 value named completed and prints it through println!. The compiler, source file, executable, process, standard output, and exit status are different objects; keep them separate when explaining evidence. Run rustc --version first. Save the complete example with a final newline, compile it with rustc --edition=2021 -D warnings hello.rs -o hello-rust, and run ./hello-rust from the same disposable folder. The first output line comes from the program. The second line, exit=0, is a terminal observation recorded immediately after the process. This run does not prove Cargo packaging, ownership of heap values, borrowing, tests, async execution, FFI, portability to another target, or production readiness.

The first Rust claim is only one source file compiled under one checked toolchain into one executable with exact output and status.

Reuse the systems evidence loop with rustc

You already know the difference among source text, a compiler, an executable, a process, standard output, and exit status. Rust keeps those objects separate. In this chapter rustc reads one hello.rs file under the Rust 2021 edition. It either reports a diagnostic or writes one local executable named hello-rust. Cargo, rustup, an IDE, a registry, and a network are not part of this first loop.

Begin in an owned disposable folder. Run rustc --version and retain the result. Save the exact four-line example with a final newline, then run rustc --edition=2021 -D warnings hello.rs -o hello-rust. The edition selects language rules; -D warnings turns warnings into build failure; hello.rs is the input; -o names the output. A successful command proves only that this source compiled under this checked compiler invocation.

Read four lines and one owned integer

fn main() declares the program entry. The opening brace begins its scope and the closing brace ends it. let completed: u8 = 1; creates one binding named completed whose value is the unsigned eight-bit integer 1. main owns this value until the scope ends. Because u8 is Copy, later formatting can read it without creating a heap owner or introducing borrowing syntax.

println! is a standard macro that formats values and writes one line to standard output. The braces around completed inside the format string request that binding's display value. The literal text around it is not a language or compiler report; it is a claim this program deliberately prints. Nothing here yet demonstrates String ownership, references, Cargo metadata, async work, or foreign code.

Compile, run, and compare two exact evidence lines

Run ./hello-rust only after the strict compile succeeds. The program must print language=Rust edition=2021 completed=1 exactly. Then inspect the immediately preceding terminal status and record exit=0 as a second line. The program did not print exit=0; your terminal observed that the process returned success. Keeping those sources separate makes later diagnosis possible.

If compilation fails, read the first diagnostic, its filename, line, and column before changing anything. If execution shows an old value, compare the saved file timestamp, build command, and executable path: a previously built binary can still run after a new build fails. Predict first, compile, run, compare, explain, and restore. This small loop is the evidence pattern reused throughout the course.

Laboratory: change one value and recover from stale output

Change only completed from 1 to 2 and write the exact expected output before compiling. Rebuild and run; only the final number may change. Then introduce one missing semicolon, predict that no new executable is justified, and observe the compiler diagnostic. Do not treat a still-existing old executable as evidence for the broken source. Restore the semicolon, rebuild, and recover the two original evidence lines.

Repeat from a clean disposable folder using only hello.rs and the documented command. Give the file and instructions to another learner and ask them to identify source, compiler, executable, process, program output, and terminal status. Completion means both learners can reproduce and explain the same result without an IDE, Cargo project, package download, administrator access, network, or private step.

CURRICULUM CONTEXTRelated courses and the course concept model