Rust comments

From wikinotes
Revision as of 00:58, 7 February 2023 by Will (talk | contribs)

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")
}