strip-indent 0.1.0

Strip leading whitespace from each line of a multi-line string, based on the least-indented line. A faithful port of the strip-indent npm package. Zero deps, no_std.
Documentation
//! Integration tests exercising the public API of `strip-indent`.

use strip_indent::{dedent, min_indent, strip_indent};

#[test]
fn heredoc_normalization() {
    let source = "        function foo() {\n            return 1;\n        }";
    assert_eq!(strip_indent(source), "function foo() {\n    return 1;\n}");
    assert_eq!(min_indent(source), 8);
}

#[test]
fn preserves_relative_indent() {
    assert_eq!(strip_indent("  a\n      b\n    c"), "a\n    b\n  c");
}

#[test]
fn idempotent_when_unindented() {
    let s = "already\n  flush";
    assert_eq!(strip_indent(s), s);
    assert_eq!(min_indent(s), 0);
}

#[test]
fn dedent_strips_surrounding_blank_lines() {
    assert_eq!(dedent("\n    a\n      b\n  "), "a\n  b");
    assert_eq!(dedent("   \n\t one\n\t two \n"), "one\ntwo ");
}