indent-string 0.1.0

Indent each line of a multi-line string. A faithful port of the indent-string npm package. Zero dependencies, no_std.
Documentation
//! Integration tests exercising the public API of `indent-string`.

use indent_string::{indent_string, indent_string_with};

#[test]
fn block_quote() {
    let text = "line one\nline two";
    assert_eq!(indent_string_with(text, 1, "> ", false), "> line one\n> line two");
}

#[test]
fn nested_indent() {
    let code = "if x {\n    y();\n}";
    assert_eq!(indent_string_with(code, 1, "    ", false), "    if x {\n        y();\n    }");
}

#[test]
fn empty_line_handling() {
    assert_eq!(indent_string("a\n\nb"), " a\n\n b");
    assert_eq!(indent_string_with("a\n\nb", 1, ".", true), ".a\n.\n.b");
}

#[test]
fn count_zero_is_identity() {
    assert_eq!(indent_string_with("anything\nhere", 0, "  ", true), "anything\nhere");
}