Conceptual
Login

Documentation Examples That Run as Tests

Rust can execute the example code inside documentation comments and fail the build if an example stops working. The kernel wires those examples into its own test framework so they run inside a booted kernel. The effect is that documentation for a kernel interface cannot quietly become wrong. When you document your own interfaces with a working example, you are also writing a test.

Questions this Concept answers

  • Why does executing documentation examples keep kernel documentation honest?