DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (1aeaa33a64f9)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
# version\_check

This tiny crate checks that the running or installed `rustc` meets some version
requirements. The version is queried by calling the Rust compiler with
`--version`. The path to the compiler is determined first via the `RUSTC`
environment variable. If it is not set, then `rustc` is used. If that fails, no
determination is made, and calls return `None`.

## Usage

Add to your `Cargo.toml` file:

```toml
[dependencies]
version_check = "0.1"
```

## Examples

Check that the running compiler is a nightly release:

```rust
extern crate version_check;

match version_check::is_nightly() {
    Some(true) => "running a nightly",
    Some(false) => "not nightly",
    None => "couldn't figure it out"
};
```

Check that the running compiler is at least version `1.13.0`:

```rust
extern crate version_check;

match version_check::is_min_version("1.13.0") {
    Some((true, version)) => format!("Yes! It's: {}", version),
    Some((false, version)) => format!("No! {} is too old!", version),
    None => "couldn't figure it out".into()
};
```

Check that the running compiler was released on or after `2016-12-18`:

```rust
extern crate version_check;

match version_check::is_min_date("2016-12-18") {
    Some((true, date)) => format!("Yes! It's: {}", date),
    Some((false, date)) => format!("No! {} is too long ago!", date),
    None => "couldn't figure it out".into()
};
```

## Alternatives

This crate is dead simple with no dependencies. If you need something more and
don't care about panicking if the version cannot be obtained or adding
dependencies, see [rustc_version](https://crates.io/crates/rustc_version).

## License

MIT. Have fun!