Skip to content

Add top level documentation comment template to cargo new #4855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,36 @@ authors = [{}]

let default_file_content : &[u8] = if i.bin {
b"\
//! This is the top-level module documentation in src/main.rs.
//!
//! This text appears on the front page of your crate's documentation;
//! preview it by running `cargo doc --open`.
//!
//! # Examples
//!
//! This is a great place to add an example of how to use your crate!
//!
//! ```
//! assert(true);
//! ```
fn main() {
println!(\"Hello, world!\");
}
"
} else {
b"\
//! This is the top-level module documentation in src/lib.rs.
//!
//! This text appears on the front page of your crate's documentation;
//! preview it by running `cargo doc --open`.
//!
//! # Examples
//!
//! This is a great place to add an example of how to use your crate!
//!
//! ```
//! assert(true);
//! ```
#[cfg(test)]
mod tests {
#[test]
Expand Down