Skip to content

Add example to comment.md to teach how to toggle a whole code block using block comments #1919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

KennedyRichard
Copy link
Contributor

Block comments allow people to uncomment/comment a whole code block by adding/removing a single '/' character.

None of the existing examples clearly demonstrates this ability, so I thought it'd be useful to do so here.

The chapter is already very small, so adding a few extra lines should be acceptable.

I actually learned this from Haskell, although I don't use it as often as Rust.

Toggling an entire code block by adding/removing a single character seems very, very useful, so I think it is worth teaching it to users and it deserves a prominent spot in this popular learning resource.

Block comments allow people to uncomment/comment a whole code block by adding/removing a single '/' character.

None of the existing examples clearly demonstrates this ability, so I thought it'd be useful to do so here.

The chapter is already very small, so adding a few extra lines should be acceptable.
@rustbot
Copy link
Collaborator

rustbot commented Apr 6, 2025

r? @marioidival

rustbot has assigned @marioidival.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@marioidival marioidival merged commit dfce4ad into rust-lang:master May 29, 2025
1 check passed
@KennedyRichard KennedyRichard deleted the patch-1 branch May 29, 2025 16:28
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jun 3, 2025
Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
rust-timer added a commit to rust-lang/rust that referenced this pull request Jun 3, 2025
Rollup merge of #141923 - rustbot:docs-update, r=ehuss

Update books

## rust-lang/book

4 commits in 230c68bc1e08f5f3228384a28cc228c81dfbd10d..634724ea85ebb08a542970bf8871ac8b0f77fd15
2025-05-29 13:16:14 UTC to 2025-05-22 21:35:03 UTC

- Chapter 10 from tech review (rust-lang/book#4379)
- Chapter 9 from tech review (rust-lang/book#4377)
- Chapter 8 from tech review (rust-lang/book#4378)
- Chapter 7 from tech review (rust-lang/book#4374)

## rust-embedded/book

3 commits in 0b8219ac23a3e09464e4e0166c768cf1c4bba0d5..10fa1e084365f23f24ad0000df541923385b73b6
2025-05-27 18:37:30 UTC to 2025-05-27 18:26:36 UTC

- portability: add reference to embedded-hal docs (rust-embedded/book#391)
- remove the unused and deprecated `multilingual` field from `book.toml` (rust-embedded/book#388)
- Ci upgrade 20250522 (rust-embedded/book#393)

## rust-lang/nomicon

4 commits in c76a20f0d987145dcedf05c5c073ce8d91f2e82a..8b61acfaea822e9ac926190bc8f15791c33336e8
2025-05-26 10:16:09 UTC to 2025-05-23 15:03:00 UTC

- Use inline const expression in unchecked-uninit.md (rust-lang/nomicon#492)
- Fix code sample output in unchecked-uninit.md (rust-lang/nomicon#491)
- Use consistent type parameters in subtyping.md (rust-lang/nomicon#493)
- Fix typo in atomics.md (rust-lang/nomicon#494)

## rust-lang/reference

1 commits in 118fd1f1f0854f50e3ae1fe4b64862aad23009ca..8e0f593a30f3b56ddb0908fb7ab9249974e08738
2025-05-31 20:12:39 UTC to 2025-05-31 20:12:39 UTC

- Minor fixes to `$crate` behavior (rust-lang/reference#1816)

## rust-lang/rust-by-example

4 commits in c9d151f9147c4808c77f0375ba3fa5d54443cb9e..21f4e32b8b40d36453fae16ec07ad4b857c445b6
2025-05-29 12:45:08 UTC to 2025-05-29 12:44:23 UTC

- Update book.toml rename `author` field to `authors` (rust-lang/rust-by-example#1917)
- Add example to comment.md to teach how to toggle a whole code block using block comments (rust-lang/rust-by-example#1919)
- The example is not meant to be compiled with out passing arguments. (rust-lang/rust-by-example#1930)
- added a shorthand for the #[should_panic(expected = "msg") (rust-lang/rust-by-example#1931)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants