merge_whitespace!() { /* proc-macro */ }Expand description
This is a procedural macro that removes multiple consecutive whitespaces from a given string literal and replaces them with a single space. Quoted text will be ignored and kept as-is.
§Example
let output = merge_whitespace!("Hello World!\r\n \"How are\" you?");
assert_eq!(output, r#"Hello World! "How are" you?"#);If you want to keep quoted text as is, you can specify a quotation mark character. Everything within a pair of these markers is kept as-is:
let output = merge_whitespace!("Hello World!\r\n \"How are\" you?", quote_char = '"');
assert_eq!(output, "Hello World! \"How are\" you?");§Return
The macro expands to the modified string literal.