The semicolon terminates statements in Rust, indicating to the compiler that a specific instruction is complete.
The semicolon terminates statements in Rust, signaling the end of an expression that does not need to return a value to the caller. Omitting it causes a compilation error because the compiler expects the statement to conclude.
fn main() {
let x = 5; // Semicolon ends the statement
println!("x is {x}"); // Semicolon ends the function call
}
The semicolon acts like a period at the end of a sentence in English. It tells the Rust compiler that a specific instruction is finished and the program should move to the next line. Without it, the compiler gets confused about where one command stops and the next begins.