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 There's a widely used crate cfg_if that allows turning the latter into an else branch. A variation of that in the standard library is approaching stabilization at <https://github.com/rust-lang/rust/issues/115585>.
Tracking issue for `cfg_select` (formerly `cfg_match`) · Issue #115585 · rust-lang/rust

Provides a native way to easily manage multiple conditional flags without having to rewrite each clause multiple times. Public API cfg_select! { unix => { fn foo() { /* unix specific functionality ...

GitHub
@chrysn I know about it but that's not the problematic part
@YaLTeR Ah, I focused on the wrong part. Indeed, the version-conditional aspect is annoying, and I don't know of any good efforts to make this better.