1 unstable release

0.1.0 Feb 3, 2022

#14 in #matches

Download history 14/week @ 2024-11-15 323/week @ 2024-11-22 231/week @ 2024-11-29 17/week @ 2024-12-06 1/week @ 2024-12-13 67/week @ 2024-12-27 45/week @ 2025-01-10 5/week @ 2025-01-17 120/week @ 2025-01-24 89/week @ 2025-01-31 545/week @ 2025-02-07 182/week @ 2025-02-14 202/week @ 2025-02-21 99/week @ 2025-02-28

1,034 downloads per month

MIT license

20KB
403 lines

rust_cfg_parser - 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:

[dependencies]
rust_cfg_parser = "0.1.0"

Example

use rust_cfg_parser::{CfgValue, parse};

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

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

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

let expr = parse("cfg(all(any(target_arch =\"x86_64\", target_arch = \"aarch64\"), target_os = \"windows\"))").unwrap();
assert_eq!(
    true,
    expr.matches(&[
        CfgValue::KeyPair("target_arch".to_string(), "x86_64".to_string()),
        CfgValue::KeyPair("target_os".to_string(), "windows".to_string())
    ])
);

License: MIT

Dependencies

~4KB