Is there any way to detect the compiler version from Rust?

In C ++, you can use something like __clang_version__ . Is there something similar for rust? I searched the Internet but found nothing.

+5
source share
1 answer

Not directly.

There is a rustc_version box that tells you the rustc version available on the command line; it is intended to be used in a build script. There's also rustc_version_runtime , which does something similar, but provides information like a run-time call (that is, it detects the compiler version at compile time, but provides it at run time).

Standard Disclaimer: Be very careful when writing down everything that depends on the compiler version. Ideally, you should check only the minimum versions for which functions are supported using semver (which both libraries support directly).

+5
source

Source: https://habr.com/ru/post/1244465/


All Articles