#version #rustc #check #minimum

build version_check

Tiny crate to check the version of the installed/running rustc

5 releases

0.1.4 Jul 5, 2018
0.1.3 Jul 10, 2017
0.1.2 Jun 3, 2017
0.1.1 Jun 2, 2017
0.1.0 Jan 15, 2017

#2 in Development tools

Download history 39974/week @ 2018-08-13 44522/week @ 2018-08-20 49283/week @ 2018-08-27 55191/week @ 2018-09-03 57571/week @ 2018-09-10 60268/week @ 2018-09-17 62079/week @ 2018-09-24 73089/week @ 2018-10-01 76605/week @ 2018-10-08 72689/week @ 2018-10-15 69187/week @ 2018-10-22 76433/week @ 2018-10-29 70993/week @ 2018-11-05

86,298 downloads per month
Used in 4,534 crates (23 directly)

MIT/Apache

13KB
137 lines

version_check

This tiny crate checks that the running or installed rustc meets some version requirements. The version is queried by calling the Rust compiler with --version. The path to the compiler is determined first via the RUSTC environment variable. If it is not set, then rustc is used. If that fails, no determination is made, and calls return None.

Usage

Add to your Cargo.toml file, typically as a build dependency:

[build-dependencies]
version_check = "0.1"

Examples

Check that the running compiler is a nightly release:

extern crate version_check;

match version_check::is_nightly() {
    Some(true) => "running a nightly",
    Some(false) => "not nightly",
    None => "couldn't figure it out"
};

Check that the running compiler is at least version 1.13.0:

extern crate version_check;

match version_check::is_min_version("1.13.0") {
    Some((true, version)) => format!("Yes! It's: {}", version),
    Some((false, version)) => format!("No! {} is too old!", version),
    None => "couldn't figure it out".into()
};

Check that the running compiler was released on or after 2016-12-18:

extern crate version_check;

match version_check::is_min_date("2016-12-18") {
    Some((true, date)) => format!("Yes! It's: {}", date),
    Some((false, date)) => format!("No! {} is too long ago!", date),
    None => "couldn't figure it out".into()
};

Alternatives

This crate is dead simple with no dependencies. If you need something more and don't care about panicking if the version cannot be obtained or adding dependencies, see rustc_version.

License

version_check is licensed under either of the following, at your option:

No runtime deps