Crate merge_whitespace_utils

Source
Expand description

§merge-whitespace-utils

This crate contains the merge_whitespace and merge_whitespace_with_quotes functions for removing multiple consecutive whitespaces from a given string, replacing them with a single space.

§Example

let query = merge_whitespace_with_quotes(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
                    }
                  }
                }
                "#,
                Some('"'),
                Some('\\'));

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 } } }"#);

Functions§

merge_whitespace
Remove multiple consecutive whitespaces from a given string and replace them with a single space. If special handling of quoted text is required, see merge_whitespace_with_quotes instead.
merge_whitespace_with_quotes
Remove multiple consecutive whitespaces from a given string literal and replace them with a single space. Quoted text will be ignored and kept as-is.