Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

specifying ranges #3

@yoshuawuyts

Description

@yoshuawuyts

rust-lang/rfcs#3036 describes a family of predicates to target minimum versions of platform APIs. For example min_libc_version would return the version of libc. It was expected that max_* variants would be specified eventually as well 1, allowing ranges of OS versions to be targeted.

Unfortunately the RFC hasn't seen any updates in a while, but the challenges it attempts to address still exist. I'm wondering whether efg could help prototype syntax to specify ranges within attributes. It'd be neat if we could target a specific version range Windows by writing something like this:

#[cfg(windows && os_version >= "6.0.6000" && os_version < "7.3.5000")]

Or possibly taking it further and allowing shorthands such as:

#[cfg(windows && "6.0.6000" <= os_version < "7.3.5000")]

I'm not sure what this feature should look like, but I think having the ability to specify ranges using shorthands would be neat as well. What do you think?

Footnotes

  1. Being able to specify the maximum OS version is useful when you're writing polyfills for older versions. This would allow a developers to say something like: "This code runs on windows 10+ only", which can be leveraged to produce more optimized code.

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