Replies: 1 comment
-
I've converted this into a general discussion because it doesn't really have any bearing on public API. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This issue is about using a build script to switch on compiler versions, rather than about a policy for managing minimum compiler versions. See #123 for that.
Cargo build scripts make it possible for a stable library to detect and automatically utilize newer compiler features when they're available in a consuming crate without dropping support for older versions, or requiring dependents to explicitly opt-in. Based on
rustc_version
's dependents this seems like a pretty common pattern. Some specific examples (that don't all userustc_version
) are:serde
which uses a build script to provide a convenient macro toSerializer
s andDeserializer
s to support 128bit numbers when available and other things.regex
which uses a build script to determine whether stable SIMD intrinsics are available.lazy_static
which uses a build script to switch on the internal implementation ofLazy
depending on the compiler version.Each of the libraries above takes a bit of a different approach to detecting specific compilers and threading that information through the library itself. Are there any pitfalls or gotchas with this pattern we could call out or implementation approaches we could recommend?
Beta Was this translation helpful? Give feedback.
All reactions