3 ms·
> Rust generates documentation from comments in Markdown syntax. Code in the docs gets run as tests. You can illustrate how a function is used and test it at th
by dcow 9y ago
> Rust generates documentation from comments in Markdown syntax. Code in the docs gets run as tests. You can illustrate how a function is used and test it at the same time:
/// Multiples the specified number by two
///
/// ```
/// assert_eq!(multiply_by_two(5), 10);
/// ```
fn multiply_by_two(x: i32) -> i32 {
x * 2
}
Okay that's pretty cool.
- ndh2 9y agoPython has that as well: https://docs.python.org/3/library/doctest.html https://docs.python.org/3/library/doctest.html
- bmn__ 9y agoPerl has that as well: http://p3rl.org/Test::Inline http://p3rl.org/Test::Inline
- theshrike79 9y agoGodoc does this too