detect_version

Function detect_version 

Source
pub fn detect_version() -> Result<RustVersion, VersionDetectionError>
Expand description

Detect the current version by executing rustc.

This should only be called at build time (usually a build script), since the rust compiler is likely unavailable at runtime. It will execute whatever command is present in the RUSTC environment variable, so should not be run in an untrusted environment.

Once the version is successfully detected, it will be cached for future runs.

ยงErrors

Returns an error if unable to execute the result compiler or unable to parse the result.

Examples found in repository?
examples/version.rs (line 2)
1pub fn main() {
2    let version = rustversion_detect::detect_version().unwrap();
3    println!("version: {}", version);
4}