0% found this document useful (0 votes)
22 views2 pages

Comments - Rust by Example

Uploaded by

Vladimír Pilát
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Comments - Rust by Example

Uploaded by

Vladimír Pilát
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Comments - Rust By Example 09.10.

2023 12:48

Comments
Any program requires comments, and Rust supports a few different varieties:

Regular comments which are ignored by the compiler:


// Line comments which go to the end of the line.
/* Block comments which go to the closing delimiter. */
Doc comments which are parsed into HTML library documentation:
/// Generate library docs for the following item.
//! Generate library docs for the enclosing item.

1 fn main() {
2 // This is an example of a line comment.
3 // There are two slashes at the beginning of the line.
4 // And nothing written after these will be read by the compiler.
5
6 // println!("Hello, world!");
7
8 // Run it. See? Now try deleting the two slashes, and run it again.
9
10 /*
11 * This is another type of comment, a block comment. In general,
12 * line comments are the recommended comment style. But block comments
13 * are extremely useful for temporarily disabling chunks of code.
14 * /* Block comments can be /* nested, */ */ so it takes only a few
15 * keystrokes to comment out everything in this main() function.
16 * /*/*/* Try it yourself! */*/*/
17 */
18
19 /*
20 Note: The previous column of `*` was entirely for style. There's
21 no actual need for it.
22 */
23
24 // You can manipulate expressions more easily with block comments
25 // than with line comments. Try deleting the comment delimiters
26 // to change the result:
27 let x = 5 + /* 90 + */ 5;
28 println!("Is `x` 10 or 100? x = {}", x);
29 }

See also:

https://doc.rust-lang.org/rust-by-example/hello/comment.html Stránka 1 ze 2
Comments - Rust By Example 09.10.2023 12:48

Library documentation

https://doc.rust-lang.org/rust-by-example/hello/comment.html Stránka 2 ze 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy