I want to use min_const_generics
in a library, but fall back to a different implemention for users of Rust 1.50 and below, where it isn't available.
e.g.
#[cfg(min_const_generics)]
mod foo {}
#[cfg(not(min_const_generics))]
mod foo {}
This doesn't work, and the only methods I've come up with are:
- use explicit crate features to opt in or out of
min_const_generics
.
- publish a new version that uses
min_const_generics
but also maintain an older version that doesn' use it.
Am I missing something or is there really no way to express this?
As is often the way, almost immediately after writing this post I found https://github.com/dtolnay/rustversion
I assume that crate wouldn't exist if there was a built-in way to do it.
3 Likes
mejrs
3
I would just use a build script. I think appropriately named cfgs are more readable than specifying rust versions everywhere. For example see https://github.com/dtolnay/semver/blob/master/build.rs
1 Like
system
Closed
4
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.