Rust comments: Difference between revisions

From wikinotes
No edit summary
Line 23: Line 23:
= Doc Comments =
= Doc Comments =
<blockquote>
<blockquote>
doc-comments are written in [[markdown]].
<syntaxhighlight lang="rust">
<syntaxhighlight lang="rust">
/// doc-comment for following item (ex: java style)
/// doc-comment for following item (ex: java style)

Revision as of 21:01, 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

doc-comments are written in markdown.

/// doc-comment for following item (ex: java style)
fn foo() {
    println!("hi")
}

fn foo() {
    //! doc-comment for enclosing item (ex: python style)
    println!("bye")
}