Which is what was in that link. I was referring to how I was not detecting nightlies in the linked code, but that it should work.
I assume you didn’t look at the link. Here is a relevant snippet:
if version_matches("1.4.0") {
println!("cargo:rustc-cfg=has_string_into_boxed_string");
}
Note that this sets a cfg which states what’s being gated here. A user seeing rust >= 1.4 has to guess what particular part of having Rust 1.4 or higher is actually relevant. Seeing has_string_into_boxed_string is unambiguous: the associated code depends on String::into_boxed_string which may not be present.
If you believe stating a version number is clearer than that, then we’ll just have to agree to disagree.
You’re seriously going to vet every nightly? And publish updates on a regular basis? And document which ones contain the performance gains and which don’t?
I mean, if you are, then I can’t say anything against that. I concede that in that respect (having libraries that automatically use nightly features not break on update), if the dev is going to keep up that level of maintenance, there isn’t any actual practical drawback for users.
I fail to see how this is any safer. Easier, yes, though I still feel having named cfgs is better for readability and maintenance than raw numbers.
By the time you get to this check, Cargo has already decided what version of a crate it’s going to try and use. We want this check in Cargo, not the compiler. That way, Cargo can exclude incompatible versions from selection entirely.