dtolnay / efg Goto Github PK
View Code? Open in Web Editor NEWConditional compilation using boolean expression syntax, rather than any(), all(), not()
License: Apache License 2.0
Conditional compilation using boolean expression syntax, rather than any(), all(), not()
License: Apache License 2.0
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?
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. โฉ
First of all, I think this crate is a great idea! It always irked me how verbose the syntax for cfg
was compared to regular Rust.
Suggestion: if we're going for syntax simplification, I'd love to also simplify frequent not(feature = "somefeature")
not only to !(feature = "somefeature")
but all the way to feature != "somefeature"
.
It feels a lot more natural to use !=
operator, but I suspect it will also require changing =
to more Rust-like ==
. It would be a breaking change, but perhaps a good thing for consistency with the rest of Rust syntax.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.