Search code examples
rustrust-cargo

How can I specify the version of Rust required for a Cargo package?


Is it possible to specify that a Cargo package requires a minimum Rust version of, for example, 1.1.0 to compile?


Solution

  • In Rust 1.56.0 you can use 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"