Comments

Rust comments are similar to C++ except they may contain Unicode because .rs files are UTF-8 encoded:

  1. /*
  2. This is a comment
  3. */
  4. // This a comment with Unicode, 你好

But in addition anything that uses triple slash /// annotation can be parsed by a tool called rustdoc to produce documentation:

  1. /// This is a comment that becomes documentation for do_thing below
  2. pub fn do_thing() {}
  3. /// Returned by server if the resource could not be found
  4. pub const NOT_FOUND = 404;

Runnining cargo doc on a project will cause HTML documentation to be produced from annotated comments within the file.

Annotation is written in Markdown format. That means you have a human readable language for writing rich-text documentation and if it’s not enough you can resort to HTML via tags.

See here for full documentation