Skip to main content

dedent

Function dedent 

Source
pub fn dedent(text: &str) -> Cow<'_, str>
Expand description

Removes common leading whitespace from each line.

This function will look at each non-empty line and determine the maximum amount of whitespace that can be removed from all lines.

Lines that consist solely of whitespace are trimmed to a blank line.


assert_eq!(dedent("
    1st line
      2nd line
    3rd line
"), "
1st line
  2nd line
3rd line
");