Rust comments

From wikinotes
Revision as of 21:17, 9 February 2023 by Will (talk | contribs) (→‎Doc Comments)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.