【问题标题】:How do I tell Cargo to run files from a directory other than "src"?如何告诉 Cargo 从“src”以外的目录运行文件?
【发布时间】:2017-12-05 22:18:48
【问题描述】:

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

【问题讨论】:

标签: rust rust-cargo


【解决方案1】:

如 cmets 中所述,可能最好将所有代码移动到“服务器”目录中。如果您不这样做,您将面临默认设置,这通常不是一个好主意。

话虽如此,你可以 specify the path to the binary or library in your Cargo.toml:

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

另见:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-04
    • 2021-11-06
    • 1970-01-01
    • 2020-11-15
    • 1970-01-01
    • 2017-02-10
    • 1970-01-01
    相关资源
    最近更新 更多