Crates.io | merge-whitespace |
lib.rs | merge-whitespace |
version | 1.0.0 |
source | src |
created_at | 2024-05-14 12:09:39.492343 |
updated_at | 2024-06-03 13:23:30.554173 |
description | Procedural macros for merging whitespace in const contexts |
homepage | https://github.com/sunsided/merge-whitespace-rs |
repository | https://github.com/sunsided/merge-whitespace-rs |
max_upload_size | |
id | 1239517 |
size | 19,490 |
This crate contains procedural macros for removing multiple consecutive whitespaces from a given string literal, replacing them with a single space.
The example below uses an optional quotation characters to keep quoted text ranges un-merged, as well as an optional escape character to ensure that quotation character literals are kept as-is.
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 } } }"#);
}