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?
rustversion::cfg_select! {
nightly => { Vec<T, A> },
_ => { Vec<T> },
}
// expands on nightly to
// Vec<T, A>
// on stable to
// Vec<T>
Note in the example above that attributes are not allowed on generic arguments, 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.
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 ofstd::cfg_select!for rust versions?Note in the example above that attributes are not allowed on generic arguments, 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.