Comments
A free lesson from Swipe Coding · Rust, level 2 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
A comment is text in your source code that the Rust compiler completely ignores — it exists purely to explain something to a human reading the code later, including future you. In Rust, // starts a line comment: everything from // to the end of that line is ignored.
// This calculates a 20% tip let tip = bill * 0.2;
For longer explanations, Rust also supports block comments with /* and */, which can span multiple lines and don't need to be repeated on every line the way // does.
/*
This program calculates a restaurant bill,
including tax and a tip.
*/
fn main() {
println!("Bill calculator");
}A block comment in Rust starts with ____ and can span multiple lines.
Comments in Rust can change how a program behaves when it runs.
Which symbol starts a single-line comment in Rust?
Printing to the Screen
10 questions · pass with 60% — just like in the app.
What does the ! at the end of println! indicate?
println! automatically adds a newline after the text it prints.
A println! format string uses ____ as a placeholder for an inserted value.
What does println!("{} scored {}", "Sam", 90) print?
println!("{} scored {}", "Sam", 90);print! works like println! but does not add a trailing newline.
The ____ macro builds and returns a formatted String instead of printing it.
Which symbol starts a single-line comment in Rust?
Comments are removed before compilation and have no effect on how a Rust program runs.
A block comment in Rust starts with ____ and can span multiple lines.
Why is println! implemented as a macro instead of an ordinary function?
Keep your streak going in Swipe Coding
Swipe through every level of Rust on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →