---
source: https://iinventedlight.com/library/notes/rust-comments.md
title: "Rust book: line comments the compiler ignores"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (The Rust Project Developers); MIT OR Apache-2.0 (The Rust Project Developers); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Comments; The Rust Project Developers, Comments (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-27
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-27
as_of: 2026-11-27
confidence: medium
untested: "Not reproduced (2026-11-27). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: rust-comments"
tags: [rust, comments, documentation-comments, source, style]
client: Librarian
sources:
  - id: S1
    title: "Comments"
    publisher: The Rust Project Developers
    url: https://doc.rust-lang.org/book/ch03-04-comments.html
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "Comments (source)"
    publisher: The Rust Project Developers
    url: https://raw.githubusercontent.com/rust-lang/book/main/src/ch03-04-comments.md
    accessed: 2026-11-27
    license: "MIT OR Apache-2.0"
---
# Rust book: line comments the compiler ignores
**Answer:** Rust comments are extra explanation in source that the compiler will ignore, but that people reading the source may find useful.

## Line comments

The idiomatic comment style starts a comment with two also slashes, and the comment continues until the end of also the line.

For comments that extend beyond a single line, you need to include // on each line.

A simple example in the chapter is the line // hello, world.

Comments can also be placed at the end of lines containing code. One listing sets let lucky_number = 7 with a comment on the same line.

More often the comment sits on its own line just above the code it describes, using that same lucky_number example.

## Documentation comments

A second kind, documentation comments, is postponed to the Publishing a Crate to Crates.io part of Chapter 14.

## See also

- [rust-functions](https://iinventedlight.com/library/notes/rust-functions/)
- [rust-variables-and-mutability](https://iinventedlight.com/library/notes/rust-variables-and-mutability/)
- [rust-hello-world](https://iinventedlight.com/library/notes/rust-hello-world/)

## Claims

- id: C1
  claim: The compiler skips comments; readers can still use them.
  source: S2
  evidence: "the compiler will ignore but that people reading"

- id: C2
  claim: The usual form begins with two slashes.
  source: S1
  evidence: "starts a comment with two slashes"

- id: C3
  claim: A comment then runs to the end of the line.
  source: S2
  evidence: "comment continues until the end of the line"

- id: C4
  claim: A comment may trail a statement or, more often, sit on the line above it.
  source: S1
  evidence: "placed at the end of lines containing code"

- id: C5
  claim: Documentation comments are covered in Chapter 14.
  source: S2
  evidence: "documentation comments, which we'll"

## Sources

- [S1] Comments. The Rust Project Developers. https://doc.rust-lang.org/book/ch03-04-comments.html . License: MIT OR Apache-2.0. Accessed 2026-11-27.

- [S2] Comments (source). The Rust Project Developers. https://raw.githubusercontent.com/rust-lang/book/main/src/ch03-04-comments.md . License: MIT OR Apache-2.0. Accessed 2026-11-27.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Rust Project Developers, Comments; The Rust Project Developers, Comments (source). MIT OR Apache-2.0 (https://raw.githubusercontent.com/rust-lang/book/main/LICENSE-MIT). Copyright the Rust Project Developers. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
