Skip to content

Equivalent of cfg_select? #69

Description

@WorldSEnder

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions