rust - 指定 Cargo 项目所需的 rustc 版本

标签 rust rust-cargo

是否可以指定 Cargo 项目需要最低 rustc 版本,例如 1.1.0 才能编译?

最佳答案

在 Rust 1.56.0 中你可以使用 rust-version :

The rust-version field is an optional key that tells cargo what version of the Rust language and compiler your package can be compiled with. If the currently selected version of the Rust compiler is older than the stated version, cargo will exit with an error, telling the user what version is required.

[package]
rust-version = "1.56"

关于rust - 指定 Cargo 项目所需的 rustc 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32821998/

相关文章:

methods - 方法调用语法 `foo.method()`和UFCS `Foo::method(&foo)`有什么区别?

rust - 如何有条件地将类型分配给引用

rust - 如何在离线状态下使用 Cargo 构建项目?

rust - 在 Rust 中通过一个 crate 访问另一个 crate

python - 在工作空间中编译时,dylib 无法加载 libstd

file - Rust 读取文件

unit-testing - 如何将特征对象的 stub 注入(inject) Rust 中的类型并保留对它的引用?

c - 重新解释内存/指针

rust - 更新我所有 rust 包的命令是什么

emacs - 如何从 Emacs 运行 cargo