3 This tiny crate checks that the running or installed `rustc` meets some version
4 requirements. The version is queried by calling the Rust compiler with
5 `--version`. The path to the compiler is determined first via the `RUSTC`
6 environment variable. If it is not set, then `rustc` is used. If that fails, no
7 determination is made, and calls return `None`.
11 Add to your `Cargo.toml` file, typically as a build dependency:
20 Check that the running compiler is a nightly release:
23 extern crate version_check;
25 match version_check::is_nightly() {
26 Some(true) => "running a nightly",
27 Some(false) => "not nightly",
28 None => "couldn't figure it out"
32 Check that the running compiler is at least version `1.13.0`:
35 extern crate version_check;
37 match version_check::is_min_version("1.13.0") {
38 Some((true, version)) => format!("Yes! It's: {}", version),
39 Some((false, version)) => format!("No! {} is too old!", version),
40 None => "couldn't figure it out".into()
44 Check that the running compiler was released on or after `2016-12-18`:
47 extern crate version_check;
49 match version_check::is_min_date("2016-12-18") {
50 Some((true, date)) => format!("Yes! It's: {}", date),
51 Some((false, date)) => format!("No! {} is too long ago!", date),
52 None => "couldn't figure it out".into()
58 This crate is dead simple with no dependencies. If you need something more and
59 don't care about panicking if the version cannot be obtained or adding
60 dependencies, see [rustc_version](https://crates.io/crates/rustc_version).
64 `version_check` is licensed under either of the following, at your option:
66 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
67 * MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)