Skip to main content

document_returns

Attribute Macro document_returns 

Source
#[document_returns]
Expand description

Generates documentation for the return value of a function.

This macro adds a “Returns” section to the function’s documentation.

§Syntax

#[document_returns("Description of the return value.")]
pub fn foo() -> i32 { ... }

§Generates

A documentation comment describing the return value.

§Examples

// Invocation
#[document_returns("The sum of x and y.")]
pub fn add(x: i32, y: i32) -> i32 { ... }

// Expanded code
/// ### Returns
/// The sum of x and y.
pub fn add(x: i32, y: i32) -> i32 { ... }