Compile time is the phase before a program starts running. During this phase, the compiler analyzes source code and reports problems while the programmer can still correct them. Rust is deliberately strict here: it moves many possible errors away from runtime debugging and gives guidance before execution. section 1.1.2
Let compiler feedback guide corrections
A small Rust program can fail at compile time because a string literal is not yet a String, push expects a char rather than a string slice, a comma is missing, or a variable is not mutable. The compiler identifies each issue and suggests corrections. Applying those suggestions produces working code, while a separate warning can flag an unused variable without preventing execution. section 1.1.2
error: expected `,`, found `my_name` | 4 | println!("{}" my_name); | ^^^^^^^ expected `,` error[E0308]: mismatched types --> src/main.rs:2:27 | 2 | let my_name: String = "Dave"; | ------ ^^^^^^- help: try using a conversion method: `.to_string()` | | | | | expected struct `String`, found `&str` | expected due to this error[E0308]: mismatched types --> src/main.rs:3:18 | 3 | my_name.push("!"); | ---- ^^^ expected `char`, found `&str` | | | arguments to this function are incorrect | help: if you meant to write a `char` literal, use single quotes | 3 | my_name.push('!'); | ~~~
Inspect representative compiler errors and suggested fixes for types, punctuation, and character literals. section 1.1.2

