0PricingLogin
Learn Rust Coding · Lesson

Doc Comments

/// documentation.

Documentation in Rust

Rust has first-class documentation built into the language. Special comments become HTML docs generated by cargo doc.

Outer Doc Comments

Use /// to document the item that follows it — functions, structs, enums, and more. The text supports Markdown.

/// Adds two numbers together.
pub fn add(a: i32, b: i32) -> i32 {
    a + b
}

All lessons in this course

  1. Unit Tests
  2. Integration Tests
  3. Doc Comments
  4. Doc Tests
← Back to Learn Rust Coding