merge-whitespace-utils 1.1.0

Procedural macros for merging whitespace in const contexts
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 10.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.15 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • sunsided/merge-whitespace-rs
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • sunsided

merge_whitespace

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

This crate contains procedural macros for removing multiple consecutive whitespaces from a given string literal, replacing them with a single space.

Example

The example below uses an optional quotation character 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 } } }"#);
}

Alternatively, the merge_whitespace_utils::merge_whitespace function can be used to process variable input.