Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

Printing to the Screen · Lesson 7 of 8

Comments

A free lesson from Swipe Coding · Rust, level 2 · updated October 2026

By the Swipe team, founded by Colin · how we make lessons

🤖
The compiler skips right over these — they're purely for the humans reading the code. 📝

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;
A line comment explaining the purpose of the line below it.

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 spanning several lines, placed above the code it describes.
Fill in the blank

A block comment in Rust starts with ____ and can span multiple lines.

True or false

Comments in Rust can change how a program behaves when it runs.

Quick check

Which symbol starts a single-line comment in Rust?

Chapter quiz

Printing to the Screen

10 questions · pass with 60% — just like in the app.

Quick check

What does the ! at the end of println! indicate?

True or false

println! automatically adds a newline after the text it prints.

Fill in the blank

A println! format string uses ____ as a placeholder for an inserted value.

Quick check

What does println!("{} scored {}", "Sam", 90) print?

println!("{} scored {}", "Sam", 90);
True or false

print! works like println! but does not add a trailing newline.

Fill in the blank

The ____ macro builds and returns a formatted String instead of printing it.

Quick check

Which symbol starts a single-line comment in Rust?

True or false

Comments are removed before compilation and have no effect on how a Rust program runs.

Fill in the blank

A block comment in Rust starts with ____ and can span multiple lines.

Quick check

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 →