Diagnostic Boot
Before you are granted access to the live production network to build Project Sentinel, you must pass the Simulation Core. This isolated environment will teach you the syntax necessary to survive Rust's strict compiler.
1. The Entry Point
Every Rust program begins execution at a single point: the main function. Inside this function, we will use a "Macro" (denoted by the ! symbol) to print text to the terminal.
fn main() {
println!("Simulation pod online.");
}
2. Immutability by Default
In languages like Python, variables can be changed at any time. In Rust, variables are locked down by default to prevent accidental data corruption. To allow a variable to change, you must explicitly declare it as mutable using mut.
fn main() {
println!("Simulation pod online.");
// The 'mut' keyword allows us to update this value later
let mut threat_level = 1;
// We increment the threat level
threat_level += 1;
println!("Current simulated threat level: {}", threat_level);
}
Verify your simulation pod is active.
Open your local Rust playground or terminal. Write out the mutable threat level program exactly as shown above, compile it, and run it. Verify that the terminal successfully outputs the incremented threat level before advancing.