#cfg #parser #expression #expr #matches #cfg-value

no-std rust_cfg_parser

rust cfg() 表达式的解析器

1 个不稳定版本

0.1.0 2022年2月3日

#2514解析器实现

Download history 184/week @ 2024-03-24 41/week @ 2024-03-31 66/week @ 2024-04-07 2/week @ 2024-04-14 9/week @ 2024-04-21 2/week @ 2024-05-12 162/week @ 2024-05-19 1/week @ 2024-05-26 79/week @ 2024-06-02 8/week @ 2024-06-09 362/week @ 2024-06-16 108/week @ 2024-06-23 274/week @ 2024-06-30 169/week @ 2024-07-07

914 每月下载量

MIT 许可证

20KB
403

rust_cfg_parser - rust cfg() 表达式的解析器

Build Status Crates.io Docs

用法

要在项目中使用 rust_cfg_parser,请将以下内容添加到您的 Cargo.toml 文件中

[dependencies]
rust_cfg_parser = "0.1.0"

示例

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())
    ])
);

许可证:MIT

依赖项

~4KB