Equivalent of `cfg_select`?
- Dominant language
- Rust
- Stars
- 394
- Forks
- 22
- PR merge metrics
- No merged PRs in 30d
Description
There are some contexts where the grammar of rust allows one macro, but not arbitrary expressions, e.g. attributes on expressions and impl heads.
Is there an interest in a `cfg_select!` macro that does the equivalent of `std::cfg_select!` for rust versions?
```rust
rustversion::cfg_select! {
nightly => { Vec },
_ => { Vec },
}
// expands on nightly to
// Vec
// on stable to
// Vec
```
Note in the example above that attributes are [not allowed on generic arguments](https://doc.rust-lang.org/reference/grammar.html#grammar-summary-GenericArgList), hence naming the full type. A type alias is also not a good option since rust checks that all parameters are used and errors when the optional allocator argument is unused.
Would be interested in this and follow up with a PR if you are too.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.