]> git.proxmox.com Git - rustc.git/blob - src/vendor/rustc_version/README.md
New upstream version 1.28.0~beta.14+dfsg1
[rustc.git] / src / vendor / rustc_version / README.md
1 rustc-version-rs
2 ==============
3
4 A library for querying the version of a `rustc` compiler.
5
6 This can be used by build scripts or other tools dealing with Rust sources
7 to 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).
14 It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
15
16 At the point of the last update of this README, the latest published version could be used like this:
17
18 Add the following dependency to your Cargo manifest...
19
20 ```toml
21 [build-dependencies]
22 rustc_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
32 extern crate rustc_version;
33 use rustc_version::{version, version_meta, Channel, Version};
34
35 fn 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
64 Licensed 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
69 at your option.
70
71 ### Contribution
72
73 Unless you explicitly state otherwise, any contribution intentionally submitted
74 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
75 additional terms or conditions.