Backed out changeset 48baafc34055 (bug 1789166) for causing mochitests failures....
[gecko.git] / third_party / rust / rustc_version / README.md
blobe76ef950dfd2cf17a50d25354d38d00bf6be6d45
1 rustc-version-rs
2 ================
4 [![Documentation](https://docs.rs/rustc_version/badge.svg)](https://docs.rs/rustc_version/)
5 [![Crates.io](https://img.shields.io/crates/v/rustc_version.svg)](https://crates.io/crates/rustc_version)
6 [![Build status](https://github.com/Kimundi/rustc-version-rs/workflows/CI/badge.svg)](https://github.com/Kimundi/rustc-version-rs/actions?query=workflow%3ACI)
8 A library for querying the version of a `rustc` compiler.
10 This can be used by build scripts or other tools dealing with Rust sources
11 to make decisions based on the version of the compiler. Current MSRV is 1.32.0.
13 If this is of interest, also consider looking at these other crates:
15 * [autocfg](https://crates.io/crates/autocfg/), which helps with feature detection instead of depending on compiler versions
16 * [rustversion](https://github.com/dtolnay/rustversion) provides a procedural macro with no other dependencies
18 # Getting Started
20 [rustc-version-rs is available on crates.io](https://crates.io/crates/rustc_version).
21 It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
23 At the point of the last update of this README, the latest published version could be used like this:
25 Add the following dependency to your Cargo manifest...
27 ```toml
28 [build-dependencies]
29 rustc_version = "0.2"
30 ```
32 ... and see the [docs](https://docs.rs/rustc_version) for how to use it.
34 # Example
36 ```rust
37 // This could be a cargo build script
39 use rustc_version::{version, version_meta, Channel, Version};
41 fn main() {
42     // Assert we haven't travelled back in time
43     assert!(version().unwrap().major >= 1);
45     // Set cfg flags depending on release channel
46     match version_meta().unwrap().channel {
47         Channel::Stable => {
48             println!("cargo:rustc-cfg=RUSTC_IS_STABLE");
49         }
50         Channel::Beta => {
51             println!("cargo:rustc-cfg=RUSTC_IS_BETA");
52         }
53         Channel::Nightly => {
54             println!("cargo:rustc-cfg=RUSTC_IS_NIGHTLY");
55         }
56         Channel::Dev => {
57             println!("cargo:rustc-cfg=RUSTC_IS_DEV");
58         }
59     }
61     // Check for a minimum version
62     if version().unwrap() >= Version::parse("1.4.0").unwrap() {
63         println!("cargo:rustc-cfg=compiler_has_important_bugfix");
64     }
66 ```
68 ## License
70 Licensed under either of
72  * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
73  * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
75 at your option.
77 ### Contribution
79 Unless you explicitly state otherwise, any contribution intentionally submitted
80 for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
81 additional terms or conditions.