-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-initCommand-newS-needs-team-inputStatus: Needs input from team on whether/how to proceed.Status: Needs input from team on whether/how to proceed.
Description
Problem
Currently, lib.rs
generated by cargo init
(or cargo new
) has no doc comments and doctests.
cargo/src/cargo/ops/cargo_new.rs
Lines 877 to 880 in 5946db3
b"\ | |
pub fn add(left: u64, right: u64) -> u64 { | |
left + right | |
} |
I think it would be better if the add
function had doc comments and doctests. I think these are useful examples of what happens when we run cargo doc
and cargo test
.
Proposed Solution
Add doc comments and doctests like this:
/// Calculates `left` + `right`.
///
/// # Examples
///
/// ```
/// let result = add(2, 2);
/// assert_eq!(result, 4);
/// ```
pub fn add(left: u64, right: u64) -> u64 {
Notes
No response
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-initCommand-newS-needs-team-inputStatus: Needs input from team on whether/how to proceed.Status: Needs input from team on whether/how to proceed.