Prompt
Each public API documentation block should follow a consistent structure:
- Start with a single-line summary that concisely describes the item
- Add an empty line after the summary
- Follow with detailed documentation paragraphs
- Use empty lines between sections (paragraphs, code blocks, headers)
- Format Rust types using backticks (e.g., [
String])
Example:
/// Receives the next value from the channel.
///
/// This method returns `None` if the channel has been closed and there are
/// no remaining messages in the channel's queue. The channel is closed when
/// all senders have been dropped.
///
/// # Examples
///
/// ```
/// use tokio::sync::mpsc;
///
/// #[tokio::main]
/// async fn main() {
/// let (tx, mut rx) = mpsc::channel(100);
/// assert!(rx.recv().await.is_none());
/// }
/// ```
pub async fn recv(&mut self) -> Option<T> {
// Implementation
}
This structure improves readability and ensures documentation is both scannable and detailed when needed. The single-line summary is particularly important as it appears in module documentation and IDE tooltips.