Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
.github/workflows/ | 12-May-2024 | - | 43 | 34 | ||
src/ | 12-May-2024 | - | 1,209 | 577 | ||
static/stable/ | 12-May-2024 | - | 495 | 393 | ||
.gitignore | D | 12-May-2024 | 18 | 3 | 2 | |
.travis.yml | D | 12-May-2024 | 63 | 7 | 6 | |
BUILD.gn | D | 12-May-2024 | 1,003 | 28 | 24 | |
Cargo.toml | D | 12-May-2024 | 423 | 14 | 12 | |
LICENSE-APACHE | D | 12-May-2024 | 10.6 KiB | 202 | 169 | |
LICENSE-MIT | D | 12-May-2024 | 1.1 KiB | 20 | 16 | |
README.OpenSource | D | 12-May-2024 | 376 | 11 | 11 | |
README.md | D | 12-May-2024 | 2.6 KiB | 81 | 57 |
README.OpenSource
1[ 2 { 3 "Name": "version_check", 4 "License": "Apache License V2.0, MIT", 5 "License File": "LICENSE-APACHE, LICENSE-MIT", 6 "Version Number": "0.9.4", 7 "Owner": "fangting12@huawei.com", 8 "Upstream URL": "https://github.com/SergioBenitez/version_check", 9 "Description": "A Rust library that provides support for checking the version of Rust being used." 10 } 11]
README.md
1# version\_check 2 3[](https://github.com/SergioBenitez/version_check/actions) 4[](https://crates.io/crates/version_check) 5[](https://docs.rs/version_check) 6 7This tiny crate checks that the running or installed `rustc` meets some version 8requirements. The version is queried by calling the Rust compiler with 9`--version`. The path to the compiler is determined first via the `RUSTC` 10environment variable. If it is not set, then `rustc` is used. If that fails, no 11determination is made, and calls return `None`. 12 13## Usage 14 15Add to your `Cargo.toml` file, typically as a build dependency: 16 17```toml 18[build-dependencies] 19version_check = "0.9" 20``` 21 22`version_check` is compatible and compiles with Rust 1.0.0 and beyond. 23 24## Examples 25 26Set a `cfg` flag in `build.rs` if the running compiler was determined to be 27at least version `1.13.0`: 28 29```rust 30extern crate version_check as rustc; 31 32if rustc::is_min_version("1.13.0").unwrap_or(false) { 33 println!("cargo:rustc-cfg=question_mark_operator"); 34} 35``` 36 37Check that the running compiler was released on or after `2018-12-18`: 38 39```rust 40extern crate version_check as rustc; 41 42match rustc::is_min_date("2018-12-18") { 43 Some(true) => "Yep! It's recent!", 44 Some(false) => "No, it's older.", 45 None => "Couldn't determine the rustc version." 46}; 47``` 48 49Check that the running compiler supports feature flags: 50 51```rust 52extern crate version_check as rustc; 53 54match rustc::is_feature_flaggable() { 55 Some(true) => "Yes! It's a dev or nightly release!", 56 Some(false) => "No, it's stable or beta.", 57 None => "Couldn't determine the rustc version." 58}; 59``` 60 61See the [rustdocs](https://docs.rs/version_check) for more examples and complete 62documentation. 63 64## Alternatives 65 66This crate is dead simple with no dependencies. If you need something more and 67don't care about panicking if the version cannot be obtained, or if you don't 68mind adding dependencies, see [rustc_version]. If you'd instead prefer a feature 69detection library that works by dynamically invoking `rustc` with a 70representative code sample, see [autocfg]. 71 72[rustc_version]: https://crates.io/crates/rustc_version 73[autocfg]: https://crates.io/crates/autocfg 74 75## License 76 77`version_check` is licensed under either of the following, at your option: 78 79 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) 80 * MIT License ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) 81