我可以修改默认的“ main.rs.rs”的内容。归档生锈?

发布于 2025-02-08 17:21:19 字数 236 浏览 3 评论 0原文

当您使用货物新名称>时,货物将创建一个带有“ main.rs”和其他文件的新项目。在“ main.rs”文件中总是写入的,

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

是否可以修改“ main.rs”文件的默认内容?如果可能的话,如何?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷路的信 2025-02-15 17:21:19

不,main.rs的初始文件内容(如果创建二进制)或lib.rs(如果创建库)为

您可以尝试使用 cargo-generate 来自GIT回购模板的项目。参见其文档有关如何使用它的信息。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文