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: <...") |
No edit summary |
||
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> | |||
<syntaxhighlight lang="rust"> | <syntaxhighlight lang="rust"> | ||
/// doc-comment for following item (ex: java style) | /// doc-comment for following item (ex: java style) | ||
Line 23: | Line 34: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Doc Comments --> |
Revision as of 00:58, 7 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
/// doc-comment for following item (ex: java style) fn foo() { println!("hi") } fn foo() { //! doc-comment for enclosing item (ex: python style) println!("bye") }