• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..15-Mar-2021-

src/H15-Mar-2021-428265

.cargo-checksum.jsonH A D15-Mar-2021575 11

Cargo.tomlH A D15-Mar-2021995 2725

LICENSE-APACHEH A D15-Mar-202110.6 KiB202169

LICENSE-MITH A D15-Mar-20211 KiB2622

README.mdH A D15-Mar-20212.3 KiB7654

README.md

1rustc-version-rs
2==============
3
4A library for querying the version of a `rustc` compiler.
5
6This can be used by build scripts or other tools dealing with Rust sources
7to make decisions based on the version of the compiler.
8
9[![Travis-CI Status](https://travis-ci.org/Kimundi/rustc-version-rs.png?branch=master)](https://travis-ci.org/Kimundi/rustc-version-rs)
10
11# Getting Started
12
13[rustc-version-rs is available on crates.io](https://crates.io/crates/rustc_version).
14It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
15
16At the point of the last update of this README, the latest published version could be used like this:
17
18Add the following dependency to your Cargo manifest...
19
20```toml
21[build-dependencies]
22rustc_version = "0.2"
23```
24
25...and see the [docs](http://kimundi.github.io/rustc-version-rs/rustc_version/index.html) for how to use it.
26
27# Example
28
29```rust
30// This could be a cargo build script
31
32extern crate rustc_version;
33use rustc_version::{version, version_meta, Channel, Version};
34
35fn main() {
36    // Assert we haven't travelled back in time
37    assert!(version().unwrap().major >= 1);
38
39    // Set cfg flags depending on release channel
40    match version_meta().unwrap().channel {
41        Channel::Stable => {
42            println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
43        }
44        Channel::Beta => {
45            println!("cargo:rustc-cfg=RUSTC_IS_BETA");
46        }
47        Channel::Nightly => {
48            println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
49        }
50        Channel::Dev => {
51            println!("cargo:rustc-cfg=RUSTC_IS_DEV");
52        }
53    }
54
55    // Check for a minimum version
56    if version().unwrap() >= Version::parse("1.4.0").unwrap() {
57        println!("cargo:rustc-cfg=compiler_has_important_bugfix");
58    }
59}
60```
61
62## License
63
64Licensed under either of
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)
68
69at your option.
70
71### Contribution
72
73Unless you explicitly state otherwise, any contribution intentionally submitted
74for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
75additional terms or conditions.
76