如何指定 Cargo.toml 的路径
How to specify the path to a Cargo.toml
我是 Rust 新手,我想构建 运行 我的项目。我使用类似的东西:
cd %project_path%
cargo run
我希望能够在一行中编写 cargo run -path %project_path%
,因为我想创建一个不允许更改工作目录的构建脚本。 cargo 似乎没有任何 -path
或 -target
键来定义目标目录,我总是收到消息
could not find Cargo.toml
in C:\WINDOWS\system32
or any parent
directory
几乎所有 cargo
子命令的 --manifest-path path/to/Cargo.toml
选项允许将其指向要使用的特定 Cargo.toml
文件,覆盖在当前目录及其父目录中搜索文件的默认设置名为 Cargo.toml
(此文件是 "manifest")。
顺便说一句,unix-y 命令通常采用 -h
或 --help
参数来打印有关其命令行选项的信息,cargo
和 rustc
也不例外。例如
$ cargo run --help
Run the main binary of the local package (src/main.rs)
Usage:
cargo run [options] [--] [<args>...]
Options:
-h, --help Print this message
--bin NAME Name of the bin target to run
--example NAME Name of the example target to run
-j N, --jobs N The number of jobs to run in parallel
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to execute
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
If neither `--bin` nor `--example` are given, then if the project only has one
bin target it will be run. Otherwise `--bin` specifies the bin target to run,
and `--example` specifies the example target to run. At most one of `--bin` or
`--example` can be provided.
All of the trailing arguments are passed to the binary to run. If you're passing
arguments to both Cargo and the binary, the ones after `--` go to the binary,
我是 Rust 新手,我想构建 运行 我的项目。我使用类似的东西:
cd %project_path%
cargo run
我希望能够在一行中编写 cargo run -path %project_path%
,因为我想创建一个不允许更改工作目录的构建脚本。 cargo 似乎没有任何 -path
或 -target
键来定义目标目录,我总是收到消息
could not find
Cargo.toml
inC:\WINDOWS\system32
or any parent directory
几乎所有 cargo
子命令的 --manifest-path path/to/Cargo.toml
选项允许将其指向要使用的特定 Cargo.toml
文件,覆盖在当前目录及其父目录中搜索文件的默认设置名为 Cargo.toml
(此文件是 "manifest")。
顺便说一句,unix-y 命令通常采用 -h
或 --help
参数来打印有关其命令行选项的信息,cargo
和 rustc
也不例外。例如
$ cargo run --help
Run the main binary of the local package (src/main.rs)
Usage:
cargo run [options] [--] [<args>...]
Options:
-h, --help Print this message
--bin NAME Name of the bin target to run
--example NAME Name of the example target to run
-j N, --jobs N The number of jobs to run in parallel
--release Build artifacts in release mode, with optimizations
--features FEATURES Space-separated list of features to also build
--no-default-features Do not build the `default` feature
--target TRIPLE Build for the target triple
--manifest-path PATH Path to the manifest to execute
-v, --verbose Use verbose output
-q, --quiet No output printed to stdout
--color WHEN Coloring: auto, always, never
If neither `--bin` nor `--example` are given, then if the project only has one
bin target it will be run. Otherwise `--bin` specifies the bin target to run,
and `--example` specifies the example target to run. At most one of `--bin` or
`--example` can be provided.
All of the trailing arguments are passed to the binary to run. If you're passing
arguments to both Cargo and the binary, the ones after `--` go to the binary,