我如何告诉 Cargo 从“src"以外的目录运行文件? [英] How do I tell Cargo to run files from a directory other than "src"?

查看:56
本文介绍了我如何告诉 Cargo 从“src"以外的目录运行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个前端项目,在 src 文件夹中有很多东西,我有机会也在服务器端使用 Rust.我所有的 Rust 服务器文件都在 server 文件夹中;我如何告诉 Cargo 运行 ./server/app.rs?

I have a front-end project that has a lot of stuff in src folder, and I have the opportunity to also use Rust on the server side. All my Rust server files are in the server folder; how can I tell Cargo to run ./server/app.rs?

推荐答案

如评论中所述,您可能将所有代码移动到服务器"目录中会更好.如果您不这样做,您将与默认值背道而驰,这通常不是一个好主意.

As stated in the comments, you are probably better off just moving all of your code into the "server" directory. If you don't, you are going to be swimming uphill against defaults, which is not usually a great idea.

话虽如此,您可以指定路径到 Cargo.toml 中的二进制文件或库:

[[bin]]
name = "quux"
path = "server/main.rs"

[lib]
name = "quux"
path = "server/lib.rs"

另见:

这篇关于我如何告诉 Cargo 从“src"以外的目录运行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆