rustc_simple_version/
lib.rs

1// License: Apache-2.0
2
3//! # rustc-simple-version
4//! Access the version of rustc used to build your application as a
5//! straightforward constant, no extra build script needed.
6//!
7//! ```
8//! use rustc_simple_version::RUSTC_VERSION;
9//!
10//! println!("Built using {}", RUSTC_VERSION);
11//! ```
12//!
13//! The value will be the exact same output as `rustc --version`.
14
15/// rustc version
16/// Should be identical to the output of `rustc --version`.
17/// # Example
18/// ```
19/// # use rustc_simple_version::RUSTC_VERSION;
20/// println!("Built using {}", RUSTC_VERSION);
21/// ```
22pub const RUSTC_VERSION: &str = env!("RUSTC_SIMPLE_VERSION");
23
24#[cfg(test)]
25mod tests {
26    use super::RUSTC_VERSION;
27
28    #[test]
29    fn test_rustc_version() {
30        assert!(RUSTC_VERSION.starts_with("rustc "));
31    }
32}