#white-space #proc-macro #graphql #string-literal

merge-whitespace

const上下文中合并空格的过程宏

2个版本 (1个稳定版)

1.0.0 2024年6月3日
0.1.0 2024年5月14日

#703 in 文本处理

Download history 124/week @ 2024-05-14 13/week @ 2024-05-21 85/week @ 2024-05-28 59/week @ 2024-06-04 8/week @ 2024-06-11

每月71次下载

EUPL-1.2

20KB
375

merge_whitespace

Crates.io Crates.io GitHub Workflow Status docs.rs codecov

此crate包含用于从给定的字符串字面量中删除多个连续空格的过程宏,并用单个空格替换。

示例

以下示例使用可选引号字符来保持引号文本范围不被合并,以及可选转义字符以确保引号字符字面量保持原样。

use merge_whitespace::merge_whitespace;

const QUERY: &str = merge_whitespace!(r#"
     query {
       users (limit: 1, filter: "bought a 12\" vinyl
                                 named \"spaces  in  space \"") {
         id
         name
         todos(order_by: {created_at: desc}, limit: 5) {
           id
           title
         }
       }
     }
     "#,
     quote_char = '"',
     escape_char = '\\');

#[test]
fn test() {
    assert_eq!(QUERY, r#"query { users (limit: 1, filter: "bought a 12\" vinyl
                                 named \"spaces  in  space \"") { id name todos(order_by: {created_at: desc}, limit: 5) { id title } } }"#);
}

依赖项

~275–730KB
~17K SLoC