]> git.proxmox.com Git - rustc.git/blob - vendor/version_check-0.1.5/README.md
New upstream version 1.42.0+dfsg0+pve1
[rustc.git] / vendor / version_check-0.1.5 / README.md
1 # version\_check
2
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`.
8
9 ## Usage
10
11 Add to your `Cargo.toml` file, typically as a build dependency:
12
13 ```toml
14 [build-dependencies]
15 version_check = "0.1"
16 ```
17
18 ## Examples
19
20 Check that the running compiler is a nightly release:
21
22 ```rust
23 extern crate version_check;
24
25 match version_check::is_nightly() {
26 Some(true) => "running a nightly",
27 Some(false) => "not nightly",
28 None => "couldn't figure it out"
29 };
30 ```
31
32 Check that the running compiler is at least version `1.13.0`:
33
34 ```rust
35 extern crate version_check;
36
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()
41 };
42 ```
43
44 Check that the running compiler was released on or after `2016-12-18`:
45
46 ```rust
47 extern crate version_check;
48
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()
53 };
54 ```
55
56 ## Alternatives
57
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).
61
62 ## License
63
64 `version_check` is licensed under either of the following, at your option:
65
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)