rustcfgparser - Parser for rust cfg() expression

Build Status Crates.io Docs

Usage

To use rust_cfg_parser in your project, add the following to your Cargo.toml:

toml [dependencies] rust_cfg_parser = "0.1.0"

Example

```rust use rustcfgparser::{CfgValue, parse};

let expr = parse("cfg(windows)").unwrap();

let matches = expr.matches(&[CfgValue::Name("linux".tostring())]); asserteq!(false, matches);

let matches = expr.matches(&[CfgValue::Name("windows".tostring())]); asserteq!(true, matches);

let expr = parse("cfg(all(any(targetarch =\"x8664\", targetarch = \"aarch64\"), targetos = \"windows\"))").unwrap(); asserteq!( true, expr.matches(&[ CfgValue::KeyPair("targetarch".tostring(), "x8664".tostring()), CfgValue::KeyPair("targetos".tostring(), "windows".tostring()) ]) ); ```

License: MIT