cfg()
expression parserCfg
is an AST for just cfg()
expressions. Target
allows target triples or cfg()
, so it's suitable for parsing targets Cargo allows in target.🈁️.dependencies
.
Target triples used by Rust don't follow its documented syntax, so sometimes os
/vendor
/env
will be shifted.
```rust extern crate parse_cfg;
let cfg = "cfg(not(unix))".parse()?; asserteq!(Cfg::Not(Cfg::Is("unix".tostring())), cfg);
let target = "powerpc64le-unknown-linux-gnu".parse()?; asserteq!(Target { arch: "powerpc64le".tostring(), vendor: "unknown".tostring(), os: "linux".tostring(), env: "gnu".to_string(), }, target); ```