What is Rust?
What is Rust?
A school report stores student names, calculates averages and makes decisions. Rust is a programming language that lets you describe these operations and compile them into a native executable. Its distinctive ownership rules help the compiler check how your program uses memory. We will learn those rules gradually; you do not need previous systems programming knowledge.
A source file is the text you write. A compiler checks it and produces an executable for a chosen platform. Running that executable performs its instructions. Rust is used for command-line tools, services and systems work, but a language does not supply every application framework. This course begins with small console programs.
What you’ll learn
- Distinguish Rust source, compilation and program output.
- Explain what memory checks can and cannot prove.
What is Rust? in action
Source: name the school
The executable enters main.
Source: name the schoolCompile: check the program
The let statement names the school text.
Compile: check the programRun: River School
The println! macro substitutes school into the braces and adds a newline.
Run: River School
Work through the Rust program
Save the complete source as main.rs in the Rust environment. No standard input is needed.
Rust 2024 · complete program
fn main() {
let school = "River School";
println!("{school}");
}Expected output
River SchoolFollow the execution
The executable enters main. The let statement names the school text. The println! macro substitutes school into the braces and adds a newline. The exclamation mark identifies a macro, a facility that expands Rust syntax during compilation.
Try the complete program in the Rust compiler. For tests, Cargo commands and local files, use the specified local environment.
Try a small variation
Your task: Would changing the school name require changing the printing operation?
Rust 2024 · complete program
fn main() {
let school = "River School";
println!("{school}");
}Worked answer
No. Change the text assigned to school. The printing operation reads that value when it runs, so the data and the operation have separate roles.
Mistakes and limits to recognize
Safe Rust prevents many memory mistakes, but compilation does not prove that a school policy is correct. Unsafe code and external interfaces introduce extra responsibilities. Native executables also need a compatible target environment.
Check your understanding
Take the idea into your next program
No. Change the text assigned to school. The printing operation reads that value when it runs, so the data and the operation have separate roles. Safe Rust prevents many memory mistakes, but compilation does not prove that a school policy is correct.
Further reading: the official Rust Book on what is rust?.
Reaching the recap and completing the quizzes are separate milestones.