Rust comments: Difference between revisions
From wikinotes
(Created page with "{{ TODO | verify and expand on doc comments }} <syntaxhighlight lang="rust"> // inline comment </syntaxhighlight> <syntaxhighlight lang="rust"> →multiline * comment: <...") |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
= Regular Comments = | |||
<blockquote> | |||
<syntaxhighlight lang="rust"> | <syntaxhighlight lang="rust"> | ||
// inline comment | // inline comment | ||
Line 11: | Line 10: | ||
*/ | */ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Regular Comments --> | |||
= Annotation Comments = | |||
<blockquote> | |||
Variable assignments can be annotated | |||
<syntaxhighlight lang="rust"> | |||
// This number is used because... | |||
let magic_number = 123; | |||
</syntaxhighlight> | |||
</blockquote><!-- Annotation Comments --> | |||
= Doc Comments = | |||
<blockquote> | |||
There are two styles of doc-comments: | |||
<syntaxhighlight lang="rust"> | <syntaxhighlight lang="rust"> | ||
// | //! document enclosing item (typically used for crates, modules) | ||
/// document following item (typically used for objects, functions) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
For more details, see [[rust documentation]]. | |||
</blockquote><!-- Doc Comments --> |
Latest revision as of 21:17, 9 February 2023
Regular Comments
// inline comment
/* multiline * comment */
Annotation Comments
Variable assignments can be annotated
// This number is used because... let magic_number = 123;
Doc Comments
There are two styles of doc-comments:
//! document enclosing item (typically used for crates, modules) /// document following item (typically used for objects, functions)For more details, see rust documentation.