One thing I'm missing in the Rust ecosystem of bindings to C libraries is easy conditional compilation based on the build-time library version. Something like the GTK_CHECK_VERSION() macros in C.

In Rust bindings, it's common to expose some baseline version API, then have feature flags to expose (and depend on) newer versions of the library. But there's no simple way to do, as a downstream user:

#[cfg(have_gtk_4_12)]
use_new_api();
#[cfg(not(have_gtk_4_12))]
fallback_with_old_api();

#rust

@YaLTeR it's some boilerplate and requires a build.rs but the code itself is easy?

https://doc.rust-lang.org/cargo/reference/build-script-examples.html#conditional-compilation

Build Script Examples - The Cargo Book

@robo9k hm, interesting. Could this perhaps somehow be developed further to where no build.rs is necessary on the consumer? Like, a way to set special cfgs directly?
@YaLTeR @robo9k indeed, having cfg-time access to dependency versions sounds like something important enough that should just work without any extra effort (and does in other languages). Cargo (if that's what's used) already knows which dependency versions it ended up selecting, why can't it set things up so that #[cfg(crate(somelib >= 1.2.3))] just works?