Can I modify the content of the default "main.rs" file in Rust?

Viewed 51

When you use cargo new <name>, cargo creates a new project with a "main.rs" and other files. In the "main.rs" file is always written

fn main() {
    println!("Hello, World!");
}

Is it possible to modify the default content of the "main.rs" file? If it is possible, how?

1 Answers

No, the initial file contents for main.rs (if creating a binary) or lib.rs (if creating a library) are hardcoded into Cargo.

You could try using cargo-generate to be able to generate Cargo projects from a Git repo template. See its documentation for information about how to use it.

Related