Expand description
A procedural macro for automatically removing common leading whitespace from multi-line strings.
§Usage
use dedent::dedent;
let formatted = dedent!(r#"
Hello
World
!"#);
assert_eq!(formatted, "Hello\n World\n !");
§How it works
The macro:
- Splits the input string into lines
- Finds the minimum indentation level among non-empty lines
- Removes that amount of whitespace from the start of each non-empty line
- Removes leading and trailing empty lines
Macros§
- dedent
- Removes common leading whitespace from a multi-line string literal.